You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide a way to have values injected into a class that are created once before any test methods are created.
If your test class has constructor with a parameter annotated with @PerClass, then JUnit Jupiter will create it once per run of the test class, using the default constructor of the class (in Kotlin, the primary constructor). That class can have non-static methods annotated with @BeforeAll, @AfterAll, @BeforeEach, or @AfterEach.
Here's an example of a class that creates a local database:
FYI: developers and third parties can already achieve comparable functionality via a custom extension that implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, and ParameterResolver.
With that in mind, I'm not convinced that JUnit Jupiter should implement such a feature itself.
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution.
Overview
Provide a way to have values injected into a class that are created once before any test methods are created.
If your test class has constructor with a parameter annotated with
@PerClass
, then JUnit Jupiter will create it once per run of the test class, using the default constructor of the class (in Kotlin, the primary constructor). That class can have non-static methods annotated with@BeforeAll
,@AfterAll
,@BeforeEach
, or@AfterEach
.Here's an example of a class that creates a local database:
You could think of this as a better version of JUnit4's
ExternalResource
rule.This could also be used to support
@BeforeAll
in Kotlin testsThis could also be used to support integration tests.
Deliverables
The text was updated successfully, but these errors were encountered: