0
0
JUnittesting~10 mins

@Execution annotation 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 import the correct package for the @Execution annotation.

JUnit
import org.junit.jupiter.api.parallel.[1];
Drag options to blanks, or click blank then click option'
ATest
BBeforeEach
CExecution
DAfterAll
Attempts:
3 left
💡 Hint
Common Mistakes
Importing @Test instead of @Execution
Using annotations from JUnit 4 packages
2fill in blank
medium

Complete the code to set the execution mode to concurrent using @Execution.

JUnit
@Execution(ExecutionMode.[1])
public class MyTests { }
Drag options to blanks, or click blank then click option'
ACONCURRENT
BSAME_THREAD
CSEQUENTIAL
DPARALLEL
Attempts:
3 left
💡 Hint
Common Mistakes
Using SAME_THREAD which runs tests sequentially
Using non-existent modes like PARALLEL
3fill in blank
hard

Fix the error in the annotation usage to correctly specify execution mode.

JUnit
@Execution(ExecutionMode.[1])
public class MyTests { }
Drag options to blanks, or click blank then click option'
ASAME_THREAD
Bparallel
Csame_thread
DCONCURRENT
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or snake_case instead of uppercase enum constants
Using invalid enum values
4fill in blank
hard

Fill both blanks to import the ExecutionMode enum and use it to run tests in the same thread.

JUnit
import org.junit.jupiter.api.parallel.[1];
@Execution(ExecutionMode.[2])
public class SampleTest { }
Drag options to blanks, or click blank then click option'
AExecutionMode
BCONCURRENT
CSAME_THREAD
DExecution
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Execution instead of ExecutionMode
Using CONCURRENT instead of SAME_THREAD
5fill in blank
hard

Fill all three blanks to create a test class that runs tests concurrently and imports both required annotations.

JUnit
import org.junit.jupiter.api.parallel.[1];
import org.junit.jupiter.api.[2];
@Execution(ExecutionMode.[3])
public class ConcurrentTests { }
Drag options to blanks, or click blank then click option'
AExecution
BTest
CCONCURRENT
DBeforeEach
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to import @Test annotation
Using wrong execution mode values