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

Allow using @ApplicationModuleTest outside of a module package #466

Open
odrotbohm opened this issue Jan 17, 2024 Discussed in #413 · 2 comments · May be fixed by #618
Open

Allow using @ApplicationModuleTest outside of a module package #466

odrotbohm opened this issue Jan 17, 2024 Discussed in #413 · 2 comments · May be fixed by #618
Assignees
Labels
in: test support Spring Boot integration testing type: enhancement Major enhanvements, new features

Comments

@odrotbohm
Copy link
Member

Discussed in #413

Originally posted by marinusgeuze December 11, 2023
Hi,

In our project, we have organized our tests into different root packages based on their types, such as unit tests, integration tests, and end-to-end tests. Consequently, our Spring Boot Integration Tests are placed in a package different from their corresponding modules, leading to the occurrence of the “Package %s is not part of any module!” error.

To provide more context, our test package structure looks something like this:

unit.com.test..*UnitTest
it.com.test..*IntegrationTest
end2end.com.test..*End2EndTest

We are seeking a solution to explicitly define the module to which a Spring Boot Integration Test belongs. This as part of the ApplicationModuleTest annotation. Or ideally, we would like to add the it.com.test package to the module. Is there a way to achieve this?

We acknowledge that a possible recommendation might be to group tests within the module boundaries, like com.test..unit.*UnitTest, com.test..it.*IntegrationTest, etc. However, this is not a feasible option for us due to the configuration constraints of our test frameworks.

@odrotbohm odrotbohm added in: test support Spring Boot integration testing type: enhancement Major enhanvements, new features labels Jan 17, 2024
@odrotbohm odrotbohm self-assigned this Jan 17, 2024
@odrotbohm
Copy link
Member Author

We could / would need to add the following attributes to @ApplicationModuleTest:

  • module (String) – the logical name of the module to bootstrap
  • classes (alias of @SpringBootTest(classes) – to explicitly point to the main application class

ModuleTestExecution would need to be altered to skip the module detection in case module is configured. Furthermore, we'd have to inspect the classes manually configured for a @SpringBootApplication annotation to detect the primary application class before falling back to the lookup via a package traversal.

@lukasdo
Copy link
Contributor

lukasdo commented May 20, 2024

@odrotbohm can I draft a PR for this issue?

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 type: enhancement Major enhanvements, new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants