Bird
0
0

Which is the correct syntax to assign a test method to groups "smoke" and "regression" in TestNG?

easy📝 Syntax Q12 of 15
Selenium Java - TestNG Integration
Which is the correct syntax to assign a test method to groups "smoke" and "regression" in TestNG?
A@Test(groups = {"smoke", "regression"})
B@Test(group = "smoke, regression")
C@Test(groups = "smoke, regression")
D@Test(groups = ["smoke", "regression"])
Step-by-Step Solution
Solution:
  1. Step 1: Recall TestNG groups syntax

    The correct syntax uses groups = {"group1", "group2"} with curly braces and double quotes for each group.
  2. Step 2: Compare options

    @Test(groups = {"smoke", "regression"}) matches the correct syntax. Options A, B, and D misuse quotes or attribute name. @Test(groups = ["smoke", "regression"]) uses square brackets which is invalid in Java annotations.
  3. Final Answer:

    @Test(groups = {"smoke", "regression"}) -> Option A
  4. Quick Check:

    Groups use curly braces and quotes [OK]
Quick Trick: Use curly braces and quotes for multiple groups [OK]
Common Mistakes:
MISTAKES
  • Using 'group' instead of 'groups'
  • Passing groups as a single string
  • Using square brackets instead of curly braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes