Complete the code to enable parallel execution of tests in JUnit 5.
@Execution(ExecutionMode.[1]) public class MyTests { @Test void testOne() { // test code } }
Using ExecutionMode.CONCURRENT tells JUnit 5 to run tests in parallel.
Complete the code to configure the JUnit Platform to run tests in parallel using a properties file.
junit.jupiter.execution.parallel.enabled = [1]Setting junit.jupiter.execution.parallel.enabled to true enables parallel test execution.
Fix the error in the annotation to correctly set the execution mode for parallel tests.
@Execution(ExecutionMode.[1]) public class SampleTest { @Test void example() { // test code } }
The correct enum value to enable parallel execution is CONCURRENT. 'PARALLEL' is not a valid value.
Fill both blanks to configure parallel execution mode and set the default parallelism in junit-platform.properties.
junit.jupiter.execution.parallel.mode.default = [1] junit.jupiter.execution.parallel.config.strategy = [2]
Setting mode.default to concurrent enables parallel tests by default. The config.strategy set to fixed uses a fixed number of threads.
Fill all three blanks to create a JUnit 5 test class that runs tests in parallel and uses a custom thread pool size.
@Execution(ExecutionMode.[1]) public class ParallelTests { @Test void testA() { // test code } } // In junit-platform.properties: junit.jupiter.execution.parallel.enabled = [2] junit.jupiter.execution.parallel.config.fixed.parallelism = [3]
The annotation uses CONCURRENT to enable parallel tests. The properties file enables parallel execution with true and sets the thread pool size to 4.