Bird
0
0

You have three test methods:

hard📝 framework Q15 of 15
Selenium Java - TestNG Integration
You have three test methods:
@Test(groups = {"sanity"})
public void testLogin() {}

@Test(groups = {"regression", "sanity"})
public void testCheckout() {}

@Test(groups = {"regression"})
public void testSearch() {}
How would you run only the tests that belong exclusively to the "sanity" group, excluding those that also belong to "regression"?
ARun tests with groups "sanity" and "regression" together
BRun all tests with group "sanity" only
CRun tests with group "regression" only
DRun tests with group "sanity" and exclude group "regression" in the TestNG XML
Step-by-Step Solution
Solution:
  1. Step 1: Identify tests with only "sanity" group

    testLogin belongs only to "sanity"; testCheckout belongs to both "regression" and "sanity"; testSearch belongs only to "regression".
  2. Step 2: Determine how to run only exclusive "sanity" tests

    Use TestNG XML to include "sanity" group and exclude "regression" group to run only testLogin.
  3. Final Answer:

    Run tests with group "sanity" and exclude group "regression" in the TestNG XML -> Option D
  4. Quick Check:

    Include "sanity" exclude "regression" = exclusive tests [OK]
Quick Trick: Include one group, exclude others in XML to filter tests [OK]
Common Mistakes:
  • Running all tests with "sanity" ignoring exclusions
  • Running "regression" group instead
  • Running both groups together without filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes