Expected Behavior
I would expect one context should be created per test case when rebuildContext is true, so that I should have at least one chance to access that context from an @AfterEach method.
Actual Behaviour
When beans are set to eager init they get created multiple times per test case. I have some suspicion that this is somehow related to why the DBUnit extension no longer works in M4 when rebuildContext is set to true but haven't had time to investigate yet.
Steps To Reproduce
@MicronautTest(rebuildContext = true)
public class RebuildContextTest {
@Inject
TestBean bean;
@Test
public void test() {
assertEquals(1, TestBean.counter); // Is 2
}
}
@Context
class TestBean {
static int counter = 0;
public TestBean() {
counter++;
}
}
Environment Information
Example Application
No response
Version
4.7.5