0
0
Selenium Javatesting~10 mins

Why TestNG structures test execution in Selenium Java - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a TestNG test method.

Selenium Java
@Test
public void [1]() {
    System.out.println("Test executed");
}
Drag options to blanks, or click blank then click option'
ArunTest
Bmain
CtestMethod
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'main' as the test method name, which is reserved for program entry.
Not annotating the method with @Test (not shown here but common).
2fill in blank
medium

Complete the code to set the priority of a TestNG test method.

Selenium Java
@Test(priority = [1])
public void testLogin() {
    // test steps
}
Drag options to blanks, or click blank then click option'
A1
B-1
C"high"
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using negative numbers for priority.
Using strings instead of integers.
3fill in blank
hard

Fix the error in the TestNG annotation to run a method before all tests.

Selenium Java
@[1]
public void setup() {
    // setup code
}
Drag options to blanks, or click blank then click option'
ABeforeSuite
BBeforeTest
CBeforeClass
DBeforeMethod
Attempts:
3 left
💡 Hint
Common Mistakes
Using @BeforeTest runs before each test tag, not the entire suite.
Using @BeforeMethod runs before each test method.
4fill in blank
hard

Fill both blanks to define a test method that depends on another method and is enabled.

Selenium Java
@Test(dependsOnMethods = {"[1]"}, enabled = [2])
public void testCheckout() {
    // test steps
}
Drag options to blanks, or click blank then click option'
AtestLogin
Btrue
Cfalse
DtestPayment
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names without quotes in dependsOnMethods.
Setting enabled to false disables the test.
5fill in blank
hard

Fill all three blanks to create a test method with a timeout, description, and alwaysRun attribute.

Selenium Java
@Test(timeout = [1], description = "[2]", alwaysRun = [3])
public void testSearch() {
    // test steps
}
Drag options to blanks, or click blank then click option'
A5000
BSearch functionality test
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using timeout as a string instead of a number.
Setting alwaysRun to false disables forced execution.