Bird
0
0

Identify the error in the following TestNG test method:

medium📝 Debug Q6 of 15
Selenium Java - TestNG Integration
Identify the error in the following TestNG test method:
@Test(priority=1)
public void testMethod() {
System.out.println("Test running");
}
AMissing semicolon after @Test annotation
BNo error, syntax is correct
Cpriority attribute should be a string
DMethod must return a boolean
Step-by-Step Solution
Solution:
  1. Step 1: Check TestNG annotation syntax

    @Test annotation with priority as integer is valid syntax in TestNG.
  2. Step 2: Verify method structure

    Method is void, has valid body, and prints output correctly. No syntax errors present.
  3. Final Answer:

    No error, syntax is correct -> Option B
  4. Quick Check:

    Valid TestNG method syntax = D [OK]
Quick Trick: TestNG @Test methods can be void with integer priority [OK]
Common Mistakes:
MISTAKES
  • Thinking annotations need semicolons
  • Using string instead of int for priority
  • Expecting return type other than void

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes