Skip to content

Spring context is not closed after a related test class is finished #915

@svarzee

Description

@svarzee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions