micronaut-test
micronaut-test copied to clipboard
Using @Property on Junit5 @Test isn't localized
Expected Behavior
When test is annotated with @Property, property value should be localized to specific test instance.
Actual Behaviour
Tests in a suite executed after test with @Property annotation will keep using value from last @Property annotated test executed instead of reverting to default . Makes test results dependent on execution order.
Steps To Reproduce
@Refreshable
class Foo(
@Property(name = "foo", defaultValue = "a") val value: String,
)
@MicronautTest
@TestMethodOrder(MethodOrderer.MethodName::class)
class PropertyScopedToTest(
private val foo: Foo,
) {
@Test
fun `1 - should be defaultValue`() {
assertEquals("a", foo.value)
}
@Test
@Property(name = "foo", value = "b")
fun `2 - override by annotation to b`() {
assertEquals("b", foo.value)
}
@Test
fun `3 - shouldn't this be defaultValue too`() {
assertEquals("a", foo.value)
}
}
Environment Information
No response
Example Application
No response
Version
3.3.0
I hit same issue. Can someone verify please this?
Right so I think we would have to shutdown and restart the context if @Property is method level. Same if type level I guess