-
Notifications
You must be signed in to change notification settings - Fork 17
Configuration Lifecycle
Tim Ward edited this page Jan 22, 2024
·
2 revisions
The osgi-test ConfigurationExtension provides automated management of Configurations, and tries to make sure that each test starts in the same state regardless of the order in which they are run by resetting the configurations.
The following order of precedence applies to configuration declarations, with later definitions overriding earlier ones:
- Configurations declared at the class level using
@WithConfiguration/@WithFactoryConfiguration Configurations declared on@BeforeAllmethods using@WithConfiguration/@WithFactoryConfiguration- Configurations injected into
@BeforeAllmethods using@InjectConfiguration Configurations declared on@BeforeEachmethods using@WithConfiguration/@WithFactoryConfiguration- Configurations injected into
@BeforeEachmethods using@InjectConfiguration - Configurations declared on
@Testmethods using@WithConfiguration/@WithFactoryConfiguration - Configurations injected into
@Testmethods using@InjectConfiguration
It is not meaningful to annotate @BeforeEach, @AfterEach, @BeforeAll or @AfterAll methods using @WithConfiguration/@WithFactoryConfiguration and this will trigger a test configuration error.
- Configurations defined or injected at the
@Testlevel will be deleted or reset immediately after test execution - Configurations defined or injected at the
@BeforeEachlevel will be deleted or reset immediately after any@AfterEachmethods have completed - Configurations defined or injected at the
@BeforeAlland class level will be deleted or reset immediately after any @AfterAll methods have completed - Any manual modifications to configurations injected using
@InjectConfigurationwill persist until the deletion or reset of the configuration, as defined above