-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Unexpected application context cache hit when testing with SpringBootTest webEnvironment MOCK and DEFINED_PORT #23085
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
Comments
This comment has been minimized.
This comment has been minimized.
I've reproduced this with 2.3.3 using the two test classes above pasted into a basic servlet web project generated on start.spring.io.
It fails in much the same with with 2.2.9. |
The problem is specific to comparing |
If we modify the |
We might be able to add a |
When writing Spring tests using both
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK)
and@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
, I am seeing the tests reuse the same application context.With
logging.level.org.springframework.test.context.cache=DEBUG
, the relevant log output:testDefinedPort
expects a real server to be started on the port specified byserver.port
. However, depending on the order of executiontestDefinedPort
may instead reuse the application context created bymockTest
. ThewebEnvironment
should form part of the cache key.The text was updated successfully, but these errors were encountered: