Bird
0
0

Examine the following TestNG code snippet:

medium📝 Debug Q6 of 15
Selenium Java - TestNG Integration
Examine the following TestNG code snippet:
@Test(dependsOnMethods = {testA})
public void testB() {}

What is the issue with this code?
AThe dependsOnMethods attribute cannot accept an array.
BThe method name testA should be enclosed in double quotes inside the array.
CThe testB method must be static to depend on testA.
DThe dependsOnMethods attribute should be replaced with dependsOnTests.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze dependsOnMethods syntax

    It requires an array of method names as strings.
  2. Step 2: Identify error

    Here, testA is not in quotes, so it's treated as a variable, causing a compile error.
  3. Final Answer:

    The method name testA should be enclosed in double quotes inside the array. -> Option B
  4. Quick Check:

    Method names must be strings in dependsOnMethods [OK]
Quick Trick: Method names in dependsOnMethods must be quoted strings [OK]
Common Mistakes:
MISTAKES
  • Omitting quotes around method names
  • Assuming dependsOnMethods accepts variables
  • Confusing dependsOnMethods with other attributes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes