Annotation Interface Execution


@API(status=STABLE, since="5.10") @Retention(RUNTIME) @Target({TYPE,METHOD}) @Inherited public @interface Execution
@Execution is used to configure the parallel execution mode of a test class or test method.

Since JUnit Jupiter 5.4, this annotation is inherited within class hierarchies.

Default Execution Mode

If this annotation is not present, ExecutionMode.SAME_THREAD is used unless a default execution mode is defined via one of the following configuration parameters:

"junit.jupiter.execution.parallel.mode.default"
Default execution mode for all classes and tests
"junit.jupiter.execution.parallel.mode.classes.default"
Default execution mode for top-level classes

"junit.jupiter.execution.parallel.mode.classes.default" overrides "junit.jupiter.execution.parallel.mode.default" for top-level classes.

The default execution mode is not applied to classes that use the PER_CLASS lifecycle or a MethodOrderer. In both cases, test methods in such test classes are only executed concurrently if the @Execution(CONCURRENT) annotation is present on the test class or method.

Since:
5.3
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The required/preferred execution mode.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The reason for using the selected execution mode.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Property name used to set the default test execution mode for top-level classes: "junit.jupiter.execution.parallel.mode.classes.default"
    static final String
    Property name used to set the default test execution mode: "junit.jupiter.execution.parallel.mode.default"
  • Field Details

    • DEFAULT_EXECUTION_MODE_PROPERTY_NAME

      @API(status=EXPERIMENTAL, since="5.9") static final String DEFAULT_EXECUTION_MODE_PROPERTY_NAME
      Property name used to set the default test execution mode: "junit.jupiter.execution.parallel.mode.default"

      This setting is only effective if parallel execution is enabled.

      Supported Values

      Supported values include names of enum constants defined in ExecutionMode, ignoring case.

      If not specified, the default is "same_thread" which corresponds to @Execution(ExecutionMode.SAME_THREAD).

      Since:
      5.4
      See Also:
    • DEFAULT_CLASSES_EXECUTION_MODE_PROPERTY_NAME

      @API(status=EXPERIMENTAL, since="5.9") static final String DEFAULT_CLASSES_EXECUTION_MODE_PROPERTY_NAME
      Property name used to set the default test execution mode for top-level classes: "junit.jupiter.execution.parallel.mode.classes.default"

      This setting is only effective if parallel execution is enabled.

      Supported Values

      Supported values include names of enum constants defined in ExecutionMode, ignoring case.

      If not specified, it will be resolved into the same value as DEFAULT_EXECUTION_MODE_PROPERTY_NAME.

      Since:
      5.4
      See Also:
  • Element Details