0
0
JUnittesting~10 mins

Parallel test configuration in JUnit - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable parallel execution of tests in JUnit 5.

JUnit
@Execution(ExecutionMode.[1])
public class MyTests {
    @Test
    void testOne() {
        // test code
    }
}
Drag options to blanks, or click blank then click option'
APARALLEL
BSAME_THREAD
CSEQUENTIAL
DCONCURRENT
Attempts:
3 left
💡 Hint
Common Mistakes
Using SAME_THREAD runs tests one after another, not in parallel.
PARALLEL is not a valid ExecutionMode enum value.
2fill in blank
medium

Complete the code to configure the JUnit Platform to run tests in parallel using a properties file.

JUnit
junit.jupiter.execution.parallel.enabled = [1]
Drag options to blanks, or click blank then click option'
Atrue
Bfalse
Cmaybe
Dauto
Attempts:
3 left
💡 Hint
Common Mistakes
Setting the value to false disables parallel execution.
Using invalid values like 'maybe' or 'auto' causes configuration errors.
3fill in blank
hard

Fix the error in the annotation to correctly set the execution mode for parallel tests.

JUnit
@Execution(ExecutionMode.[1])
public class SampleTest {
    @Test
    void example() {
        // test code
    }
}
Drag options to blanks, or click blank then click option'
ASEQUENTIAL
BCONCURRENT
CSYNCHRONIZED
DPARALLEL
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'PARALLEL' causes a compilation error because it is not defined.
Using 'SYNCHRONIZED' or 'SEQUENTIAL' runs tests one by one.
4fill in blank
hard

Fill both blanks to configure parallel execution mode and set the default parallelism in junit-platform.properties.

JUnit
junit.jupiter.execution.parallel.mode.default = [1]
junit.jupiter.execution.parallel.config.strategy = [2]
Drag options to blanks, or click blank then click option'
Aconcurrent
Bfixed
Csequential
Ddynamic
Attempts:
3 left
💡 Hint
Common Mistakes
Setting mode to 'sequential' disables parallelism.
Using 'dynamic' strategy changes thread count at runtime, not fixed.
5fill in blank
hard

Fill all three blanks to create a JUnit 5 test class that runs tests in parallel and uses a custom thread pool size.

JUnit
@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]
Drag options to blanks, or click blank then click option'
ACONCURRENT
Btrue
C4
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Setting parallel.enabled to false disables parallel tests.
Using SEQUENTIAL mode runs tests one by one.