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

a "plain" unit test behaves like a "Spring" test if I run it together with a "Spring" test. #4319

Open
gusega opened this issue Feb 14, 2025 · 2 comments

Comments

@gusega
Copy link

gusega commented Feb 14, 2025

Hello,

For my application I have a plain unit test and a test that uses "spring-test" in 2 separate test files in a single maven module

I annotate my unit test with

@ExtendWith(MockitoExtension.class)
and the test method itself with @ExtendWith(OutputCaptureExtension.class)

I annotate my spring test with

@ExtendWith(SpringExtension.class)

If I run unit test alone, both in intellij and via maven, it runs as a "plain" unit test, as expected.

If I run both spring test and and junit test together, then my "plain" test becomes a spring test, which I don't expect.

The consequence of this is that plain unit test prints spring banner and logging picks up logback-spring.xml.

My tests are using

  1. junit-jupiter-api version 5.10.5
  2. Spring version 6.1.15

Please let me know if you want me to provide additional information or a sample repository.

Thanks

@gusega gusega changed the title a "plain" unit test creates spring context if I run it together with a "Spring" test. a "plain" unit test behaves like a spring test if I run it together with a "Spring" test. Feb 14, 2025
@gusega gusega changed the title a "plain" unit test behaves like a spring test if I run it together with a "Spring" test. a "plain" unit test behaves like a "Spring" test if I run it together with a "Spring" test. Feb 14, 2025
@marcphilipp
Copy link
Member

Please let me know if you want me to provide additional information or a sample repository.

Yes, please, that would be most helpful!

Copy link

github-actions bot commented Mar 1, 2025

If you would like us to be able to process this issue, please provide the requested information. If the information is not provided within the next 3 weeks, we will be unable to proceed and this issue will be closed.

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

No branches or pull requests

2 participants