Bird
0
0

You want to run test classes in parallel but ensure each class uses its own WebDriver instance to avoid conflicts. Which TestNG XML configuration is best?

hard📝 framework Q15 of 15
Selenium Java - TestNG Integration
You want to run test classes in parallel but ensure each class uses its own WebDriver instance to avoid conflicts. Which TestNG XML configuration is best?
A<code><suite name="Suite" parallel="instances" thread-count="4"></code>
B<code><suite name="Suite" parallel="tests" thread-count="4"></code>
C<code><suite name="Suite" parallel="methods" thread-count="4"></code>
D<code><suite name="Suite" parallel="classes" thread-count="4"></code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand parallel modes in TestNG

    parallel="classes" runs test classes in parallel, isolating each class's WebDriver instance.
  2. Step 2: Match requirement to configuration

    Running classes in parallel with thread-count=4 allows 4 classes to run simultaneously, each with its own driver.
  3. Final Answer:

    <suite name="Suite" parallel="classes" thread-count="4"> -> Option D
  4. Quick Check:

    parallel="classes" isolates WebDriver per class [OK]
Quick Trick: Use parallel="classes" for separate WebDriver per class [OK]
Common Mistakes:
  • Using parallel="methods" causing shared driver issues
  • Choosing parallel="tests" which runs test tags, not classes
  • Using parallel="instances" which is less common and may confuse

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes