Complete the code to define a TestNG test method.
@Test public void [1]() { System.out.println("Test executed"); }
The method annotated with @Test is the test method TestNG runs. Naming it testMethod is a clear convention.
Complete the code to set the priority of a TestNG test method.
@Test(priority = [1])
public void testLogin() {
// test steps
}TestNG priority is an integer starting from 0 or higher. Lower numbers run first.
Fix the error in the TestNG annotation to run a method before all tests.
@[1]
public void setup() {
// setup code
}@BeforeSuite runs once before all tests in the suite, which is the correct annotation to run setup before all tests.
Fill both blanks to define a test method that depends on another method and is enabled.
@Test(dependsOnMethods = {"[1]"}, enabled = [2])
public void testCheckout() {
// test steps
}The test testCheckout depends on testLogin and is enabled to run.
Fill all three blanks to create a test method with a timeout, description, and alwaysRun attribute.
@Test(timeout = [1], description = "[2]", alwaysRun = [3]) public void testSearch() { // test steps }
The test has a timeout of 5000 milliseconds, a description for clarity, and alwaysRun set to true to ensure it runs even if dependencies fail.