I create two test classes:
@SpringBootTest class Spec1 extends Specification { ... }
@SpringBootTest class Spec2 extends Specification { ... }
They are both run (e.g. using mvn test).
Assuming that the tests are run in order: Spec1, Spec2.
A spring context is created for Spec1 and another one for Spec2.
Currently the spring context for Spec1 is not closed before running Spec2, the spring context for Spec1 is destroyed together with spring context for Spec2 after all tests are finished.
Current behavior causes that a bean A possessed by Spec1 context is alive during Spec2 execution and thus Spec1 and Spec2 tests are not really self contained.
Assume that you create a queue consumer bean. If the bean for Spec1 is alive during Spec2 execution, messages that are expected to be consumed by Spec2 queue consumer could be consumed by Spec1 queue consumer which imho is unexpected behavior.
I create two test classes:
@SpringBootTest class Spec1 extends Specification { ... }@SpringBootTest class Spec2 extends Specification { ... }They are both run (e.g. using
mvn test).Assuming that the tests are run in order: Spec1, Spec2.
A spring context is created for Spec1 and another one for Spec2.
Currently the spring context for Spec1 is not closed before running Spec2, the spring context for Spec1 is destroyed together with spring context for Spec2 after all tests are finished.
Current behavior causes that a bean
Apossessed by Spec1 context is alive during Spec2 execution and thus Spec1 and Spec2 tests are not really self contained.Assume that you create a queue consumer bean. If the bean for Spec1 is alive during Spec2 execution, messages that are expected to be consumed by Spec2 queue consumer could be consumed by Spec1 queue consumer which imho is unexpected behavior.