Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the TestNG annotation for test methods.
Selenium Java
import org.testng.annotations.[1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect annotation names like @TestCase or @TestMethod.
Forgetting to import the annotation.
✗ Incorrect
The correct import for TestNG test methods is org.testng.annotations.Test.
2fill in blank
mediumComplete the code to define a simple TestNG test method.
Selenium Java
@[1] public void sampleTest() { System.out.println("Test running"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @TestCase or other incorrect annotations.
Missing the @ symbol before the annotation.
✗ Incorrect
The @Test annotation marks a method as a TestNG test method.
3fill in blank
hardFix the error in the TestNG test method to enable default reporting.
Selenium Java
@Test
public void testMethod() {
int expected = 5;
int actual = 3 + 2;
Assert.[1](expected, actual);
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertTrue with two arguments causes errors.
Using assertNull when values are not null.
✗ Incorrect
Use Assert.assertEquals to compare expected and actual values for TestNG reports.
4fill in blank
hardFill in the blank to create a TestNG test that fails and logs a message.
Selenium Java
@Test
public void testFailure() {
Assert.[1]("test failed");
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assertTrue(false) instead of fail() to fail a test.
Not providing a failure message.
✗ Incorrect
The Assert.fail method fails the test immediately with a message.
5fill in blank
hardFill all three blanks to create a TestNG test with a priority and description.
Selenium Java
@Test(priority = [1], description = "[2]") public void testPriority() { Assert.[3](true); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using priority as a string instead of a number.
Missing the description string.
Using assertFalse(true) which fails the test.
✗ Incorrect
Priority 0 runs before priority 1. The description explains the test. assertTrue(true) passes the test.