Bird
0
0

Identify the error in this TestNG test dependency code:

medium📝 Debug Q14 of 15
Selenium Java - TestNG Integration
Identify the error in this TestNG test dependency code:
@Test(dependsOnMethods = "setup")
public void testFeature() {}

@Test
public void setup() {}
Asetup method must be private
BtestFeature should not depend on setup
CdependsOnMethods should be an array of strings, not a single string
Dsetup method must have parameters
Step-by-Step Solution
Solution:
  1. Step 1: Check dependsOnMethods syntax

    The attribute dependsOnMethods requires an array of method names, even if only one method is listed.
  2. Step 2: Identify the syntax mistake

    Here, dependsOnMethods = "setup" is a single string, missing braces to make it an array.
  3. Final Answer:

    dependsOnMethods should be an array of strings, not a single string -> Option C
  4. Quick Check:

    dependsOnMethods needs braces for method names [OK]
Quick Trick: Always use braces {} for dependsOnMethods even if one method [OK]
Common Mistakes:
  • Using single string instead of string array
  • Making dependent method private
  • Adding parameters to setup method unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes