Skip to content

Improve test context cleanup #1475

@MarcoMartins86

Description

@MarcoMartins86

Type: Feature

Is your feature request related to a problem? Yes
While performing sequential IT tests, I often encounter the issue where the SQSListener bean is not cleared between tests, which makes it challenging to conduct real IT tests.

Describe the solution you'd like
Ability for the Spring Cloud AWS test context to be cleaned between test classes without the use of @DirtiesContext.

Describe alternatives you've considered

  • Using the @DirtiesContext works, but then tests will take much more time to run.
  • Doing almost the full IT. Bypassing the first step of sending the message to the localstack SQS and doing it by calling the listener method with the object directly.

Additional context

  1. I have a replicator project where to replicate this issue, I need to launch a WireMock server per test class, and if I don't do it, the issue doesn't happen. However, this is happening to me in other, more complex projects that don't use WireMock, which I can't share. That's why I think this is a behavior with Spring Cloud AWS.
  2. The replicator https://github.com/MarcoMartins86/spring-issue-replicator#
  3. Run mvn clean install, the test that fails is where the issue is happening, and we can see in the output something like Listener from [Test1] consuming message from [Test3], which means that the bean of another test was not destroyed between test classes and consumed the message.
  4. You can uncomment the //@DirtiesContext in IntegrationTest and run again to see they will all pass now.
  5. Please do take a look. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions