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

Parameters present in @SpringBootTest missing in @ApplicationModuleTest #890

Open
aahlenst opened this issue Oct 21, 2024 · 2 comments
Open
Assignees
Labels
in: test support Spring Boot integration testing meta: waiting for feedback Waiting for feedback of the original reporter type: improvement Minor improvements

Comments

@aahlenst
Copy link
Contributor

@SpringBootTest (as of Spring Boot 3.4.0 M3) defines additional parameters not present in @ApplicationModuleTest: properties, useMainMethod, and args. I especially miss properties. For example, I use it to tell Flyway that it is okay to clean my database as part of the test lifecycle (spring.flyway.clean-disabled=true). While there are alternative methods to inject additional properties into the environment, for example, @DynamicPropertySource, the advantage of @SpringBootTest is its ease of use and that it is in a place where the properties are easy to find.

As an aside, I think it woul be great if @SpringBootTest and @ApplicationModuleTest could be separated or a separate annotation would be introduced that I could slap onto a normal @SpringBootTest or any other slice test. That would provide me the missing parameters of @SpringBootTest and allow me to use Modulith's testing facilities in any slice test (like @JooqTest).

@odrotbohm
Copy link
Member

That's definitely an area of improvement we have on our radar. The latter is currently not possible due to the way that Boot implements the slice annotations. We're planning to improve that for 1.4 (May '25).

For the former, have you tried adding @SpringBootTest on your test class and applying the customizations in that re-declaration? The way the composed annotation mechanism works, the locally declared attribute values should trump the meta-annotated defaults.

@odrotbohm odrotbohm self-assigned this Oct 22, 2024
@odrotbohm odrotbohm added in: test support Spring Boot integration testing meta: waiting for feedback Waiting for feedback of the original reporter type: improvement Minor improvements labels Oct 22, 2024
@odrotbohm odrotbohm changed the title Parameters present in @SpringBootTest missing in @ApplicationModuleTest Parameters present in @SpringBootTest missing in @ApplicationModuleTest Oct 22, 2024
@aahlenst
Copy link
Contributor Author

For the former, have you tried adding @SpringBootTest on your test class and applying the customizations in that re-declaration? The way the composed annotation mechanism works, the locally declared attribute values should trump the meta-annotated defaults.

They do, indeed. Thanks for the hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test support Spring Boot integration testing meta: waiting for feedback Waiting for feedback of the original reporter type: improvement Minor improvements
Projects
None yet
Development

No branches or pull requests

2 participants