Challenge - 5 Problems
Parallel Test Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
JUnit Parallel Execution Output
Given the following JUnit 5 test class configured to run tests in parallel, what will be the output order of the test methods?
JUnit
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; @Execution(ExecutionMode.CONCURRENT) public class ParallelTest { @Test void testA() throws InterruptedException { Thread.sleep(100); System.out.println("A"); } @Test void testB() { System.out.println("B"); } @Test void testC() throws InterruptedException { Thread.sleep(50); System.out.println("C"); } }
Attempts:
2 left
💡 Hint
Consider that tests run concurrently and sleep delays affect output timing.
✗ Incorrect
Since testB has no delay, it prints immediately. testC sleeps 50ms, testA sleeps 100ms. So output order is B, then C, then A.
❓ assertion
intermediate1:30remaining
Correct Assertion for Parallel Test Count
In a JUnit 5 test suite configured with
junit.jupiter.execution.parallel.enabled = true and junit.jupiter.execution.parallel.config.fixed.parallelism = 3, which assertion correctly verifies that exactly 3 tests run in parallel?Attempts:
2 left
💡 Hint
The fixed parallelism config sets the exact number of parallel threads.
✗ Incorrect
The fixed.parallelism property sets the exact number of threads, so the assertion must check equality to 3.
🔧 Debug
advanced2:00remaining
Debugging Parallel Test Failures
A JUnit 5 test suite runs tests in parallel but intermittently fails due to shared resource conflicts. Which change best fixes this issue?
Attempts:
2 left
💡 Hint
JUnit 5 provides annotations to control resource locking in parallel tests.
✗ Incorrect
Using @ResourceLock ensures tests accessing the same resource do not run simultaneously, preventing conflicts.
❓ framework
advanced1:30remaining
JUnit 5 Parallel Execution Configuration
Which configuration snippet correctly enables parallel test execution with a fixed thread pool of 4 threads in JUnit 5?
Attempts:
2 left
💡 Hint
Parallel execution must be enabled and strategy set to fixed with desired parallelism.
✗ Incorrect
Option B correctly enables parallel execution with fixed strategy and sets parallelism to 4 threads.
🧠 Conceptual
expert2:30remaining
Impact of Parallel Test Execution on Test Isolation
Which statement best describes the impact of enabling parallel test execution in JUnit 5 on test isolation?
Attempts:
2 left
💡 Hint
Think about how shared data affects tests running at the same time.
✗ Incorrect
Parallel execution runs tests concurrently, so if tests share mutable state without proper isolation, conflicts can occur.