micronaut-projects / micronaut-projects/micronaut-test
Using @Property on Junit5 @Test isn't localized
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 97
- Forks
- 68
- Avg merge
- 16h 6m
- Merged PRs (30d)
- 15
Description
### 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
```kotlin
@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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PropertyScopedToTest reproducer and its ordered JUnit 5 test methods, then trace how @Property is applied around each test instance. Confirm the lifecycle behavior that leaves "foo" set to "b" after the second test. Done means the third test observes the default value "a" without depending on execution order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100