Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign the test to the group named "smoke".
Selenium Java
@Test(groups = {"[1]"})
public void testLogin() {
// test code here
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a group name that does not match the test purpose.
Forgetting to put the group name inside quotes.
✗ Incorrect
The @Test annotation's groups attribute takes the group name as a string. Here, "smoke" is the correct group name.
2fill in blank
mediumComplete the code to run only tests in the "regression" group using TestNG XML.
Selenium Java
<suite name="Suite1"> <test name="Test1"> <groups> <run> <include name="[1]"/> </run> </groups> <classes> <class name="tests.LoginTest"/> </classes> </test> </suite>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a group name not defined in the tests.
Forgetting to include the tag inside .
✗ Incorrect
The tag inside specifies which group to run. Here, "regression" is the group to include.
3fill in blank
hardFix the error in the TestNG XML to exclude the "performance" group.
Selenium Java
<suite name="Suite2"> <test name="Test2"> <groups> <run> <exclude name="[1]"/> </run> </groups> <classes> <class name="tests.PaymentTest"/> </classes> </test> </suite>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using instead of to exclude groups.
Misspelling the group name.
✗ Incorrect
The tag excludes the specified group from running. Here, "performance" is the group to exclude.
4fill in blank
hardFill both blanks to assign the test to both "smoke" and "regression" groups.
Selenium Java
@Test(groups = {"[1]", "[2]"})
public void testCheckout() {
// test code here
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put group names inside quotes.
Using only one group name when multiple are needed.
✗ Incorrect
The groups attribute accepts multiple group names as strings in an array. Here, "smoke" and "regression" are assigned.
5fill in blank
hardFill all three blanks to create a TestNG XML that runs "smoke" and "regression" groups but excludes "performance".
Selenium Java
<suite name="Suite3"> <test name="Test3"> <groups> <run> <include name="[1]"/> <include name="[2]"/> <exclude name="[3]"/> </run> </groups> <classes> <class name="tests.OrderTest"/> </classes> </test> </suite>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up include and exclude tags.
Using wrong group names or misspelling them.
✗ Incorrect
The tags specify groups to run, here "smoke" and "regression". The tag excludes "performance".