Skip to content

Introduce configuration parameter for setting default test instance lifecycle semantics #905

Closed
@sbrannen

Description

@sbrannen

Overview

For teams that prefer per-class test instance lifecycle semantics, in order to prevent such teams from having to copy-n-paste @TestInstance(Lifecycle.PER_CLASS) across the code base, it would be beneficial to introduce a configuration flag (e.g., system property) that allows the default test instance lifecycle semantics to be set on a per-project basis (e.g., for a build).

Switching the default semantics would remain an opt-in decision but would be considerably less intrusive with the configuration flag.

See #419 (comment) for background information.

In addition, we could introduce support for setting ConfigurationParameters via a properties file (e.g., a junit.properties file in the root of the classpath). This would allow such configuration to be contained in the project itself (and checked into a VCS) as opposed to having to set such a flag in the build script as well as in the IDE (perhaps on a per test run basis).

Related Issues

Deliverables

  • Introduce junit.jupiter.testinstance.lifecycle.default configuration parameter for setting default test instance lifecycle semantics.
    • Introduce new constant in org.junit.jupiter.engine.Constants.
    • Support enum constant names from TestInstance.Lifecycle, ignoring case.
    • Introduce unit tests for the new configuration parameter.
    • Introduce integration tests for the new configuration parameter, including override semantics for local config, config params provided to the launcher, and system properties.
  • Log INFO message if the test instance lifecycle mode has been set via the configuration parameter.
  • Update JavaDoc for @TestInstance.
  • Update User Guide.
  • Update release notes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions