Bird
0
0

You want to run two test classes LoginTest and PaymentTest in parallel but limit total threads to 1 in testng.xml. Which configuration achieves this?

hard📝 framework Q15 of 15
Selenium Java - TestNG Integration
You want to run two test classes LoginTest and PaymentTest in parallel but limit total threads to 1 in testng.xml. Which configuration achieves this?
A<suite name="Suite" parallel="classes" thread-count="1"> <test name="Test"> <classes> <class name="LoginTest"/> <class name="PaymentTest"/> </classes> </test> </suite>
B<suite name="Suite" parallel="tests" thread-count="2"> <test name="Test1"> <classes><class name="LoginTest"/></classes> </test> <test name="Test2"> <classes><class name="PaymentTest"/></classes> </test> </suite>
C<suite name="Suite" parallel="methods" thread-count="1"> <test name="Test"> <classes> <class name="LoginTest"/> <class name="PaymentTest"/> </classes> </test> </suite>
D<suite name="Suite"> <test name="Test"> <classes> <class name="LoginTest"/> <class name="PaymentTest"/> </classes> </test> </suite>
Step-by-Step Solution
Solution:
  1. Step 1: Understand parallel and thread-count attributes

    Setting parallel="classes" runs test classes in parallel, and thread-count="1" limits to one thread, so classes run one at a time.
  2. Step 2: Check options for matching configuration

    sets parallel to classes and thread-count to 1, matching the requirement.
  3. Final Answer:

    Option A configuration runs classes in parallel but limits threads to 1 -> Option A
  4. Quick Check:

    parallel="classes" + thread-count=1 = [OK]
Quick Trick: parallel="classes" with thread-count=1 runs classes sequentially [OK]
Common Mistakes:
MISTAKES
  • Using parallel="tests" with thread-count > 1 runs multiple threads
  • Omitting parallel attribute runs tests sequentially
  • Confusing parallel="methods" with classes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes