Challenge - 5 Problems
Parallel Execution Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of TestNG Parallel Execution Configuration
Given the following TestNG XML configuration for parallel execution, what will be the output order of test methods if each test prints its method name when run?
Selenium Java
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd"> <suite name="Suite" parallel="methods" thread-count="2"> <test name="Test1"> <classes> <class name="tests.SampleTest"/> </classes> </test> </suite> // SampleTest.java package tests; import org.testng.annotations.Test; public class SampleTest { @Test public void testA() { System.out.println("testA"); } @Test public void testB() { System.out.println("testB"); } @Test public void testC() { System.out.println("testC"); } }
Attempts:
2 left
💡 Hint
Parallel execution with thread-count=2 means up to 2 tests run at the same time, order is not guaranteed.
✗ Incorrect
With parallel="methods" and thread-count=2, TestNG runs up to 2 test methods simultaneously. The order of printed output can vary because tests run concurrently, but all tests will run.
❓ assertion
intermediate2:00remaining
Correct Assertion for Parallel Test Execution Completion
In a Selenium TestNG parallel test suite, which assertion correctly verifies that all tests have completed execution before proceeding?
Selenium Java
import org.testng.Assert; import org.testng.annotations.Test; @Test public void verifyAllTestsCompleted() { boolean allTestsDone = TestExecutionListener.allTestsFinished(); // Which assertion below is correct to confirm all tests finished? }
Attempts:
2 left
💡 Hint
You want to confirm the boolean flag is true indicating completion.
✗ Incorrect
The variable allTestsDone is true when all tests finish. Assert.assertTrue checks this condition correctly.
🔧 Debug
advanced2:00remaining
Debugging Thread Safety Issue in Parallel Selenium Tests
You have configured parallel execution in TestNG with thread-count=3. Your Selenium tests share a WebDriver instance stored in a static variable. What problem will most likely occur?
Attempts:
2 left
💡 Hint
Consider thread safety when sharing objects in parallel tests.
✗ Incorrect
Sharing a single WebDriver instance across multiple threads causes conflicts and unpredictable failures because WebDriver is not thread-safe.
❓ framework
advanced2:00remaining
Best Practice for Parallel Execution in Selenium with TestNG
Which TestNG suite XML configuration snippet correctly enables parallel execution at the class level with 4 threads?
Attempts:
2 left
💡 Hint
Parallel at class level means parallel="classes" in suite tag.
✗ Incorrect
Setting parallel="classes" with thread-count=4 runs test classes in parallel with up to 4 threads.
🧠 Conceptual
expert2:00remaining
Impact of Parallel Execution on Test Data Management
In a Selenium TestNG suite running tests in parallel, what is the best approach to manage test data to avoid flaky tests?
Attempts:
2 left
💡 Hint
Think about data isolation in parallel environments.
✗ Incorrect
Sharing data without isolation causes race conditions and flaky tests. Using thread-local or separate data per thread ensures test independence.