Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualize the problem with @DirtiesContext #1

Merged
merged 2 commits into from
Jun 22, 2020

Conversation

rieckpil
Copy link
Contributor

@rieckpil rieckpil commented Jun 22, 2020

Referring to the question on StackOverflow

if you now run ./gradlew test -i --rerun-tasks without the use of @DirtiesContext you should see the following:

JMSConsumerIntegrationTest > shouldInvokeRepositoryWhenGreetedWithASpecificMessage() STANDARD_OUT
    --- Send from context: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@3b776a76, started on Mon Jun 22 08:33:50 CEST 2020
    --- Consumed by context: org.springframework.web.context.support.GenericWebApplicationContext@235dfc4d, started on Mon Jun 22 08:33:48 CEST 2020

with using @DirtiesContext and therefore shutting down application contexts from the previous tests:

JMSConsumerIntegrationTest > shouldInvokeRepositoryWhenGreetedWithASpecificMessage() STANDARD_OUT
    Sending message in context: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@35828e64, started on Mon Jun 22 08:21:17 CEST 2020
    consumed!
    org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@35828e64, started on Mon Jun 22 08:21:17 CEST 2020

With the second commit, you are now able to run all tests together without the need for @DirtiesContext.

@ajaydivakaran ajaydivakaran merged commit 3d237c7 into ajaydivakaran:master Jun 22, 2020
@ajaydivakaran
Copy link
Owner

@rieckpil Thanks for taking the time to do this.

@rieckpil
Copy link
Contributor Author

you are welcome @ajaydivakaran 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants