-
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@BeforeAll
methods using@WithConfiguration
/@WithFactoryConfiguration
- Configurations injected into
@BeforeAll
methods using@InjectConfiguration
Configurations declared on@BeforeEach
methods using@WithConfiguration
/@WithFactoryConfiguration
- Configurations injected into
@BeforeEach
methods using@InjectConfiguration
- Configurations declared on
@Test
methods using@WithConfiguration
/@WithFactoryConfiguration
- Configurations injected into
@Test
methods 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
@Test
level will be deleted or reset immediately after test execution - Configurations defined or injected at the
@BeforeEach
level will be deleted or reset immediately after any@AfterEach
methods have completed - Configurations defined or injected at the
@BeforeAll
and class level will be deleted or reset immediately after any @AfterAll methods have completed - Any manual modifications to configurations injected using
@InjectConfiguration
will persist until the deletion or reset of the configuration, as defined above