-
Notifications
You must be signed in to change notification settings - Fork 41.2k
spring-boot.run.useTestClasspath does not take target/test-classes in account #36115
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
Looking at the original PR, it was intentional that only test dependencies are included. That said, the PR cites Jetty's Maven plugin as a source of inspiration and even around the time of Jetty 7 it has a property named
That continues to be the case in Jetty 11. The new I'd like to discuss this with the rest of the team. We need to decide:
|
Maybe a little more background for the use case: Since we do not like to bootstrap all application layers (services, repositories), which would require a full-blown application.yaml and maybe external systems, we just like to fire up the rest layer and mock all dependency beans. This works very well when placing a stripped down starter class in the test classpath, since we can use mockito for the purpose of mocking the dependency beans. |
Given that we think the current behavior is intentional, we think we should add a new feature to support more options. We think it will be possible to have |
Have you all thought about maybe adding two more goals:
The |
We use the E.g.: <useTestClasspath>true</useTestClasspath>
<additionalClasspathElements>
<additionalClasspathElement>${project.build.testOutputDirectory}
</additionalClasspathElement>
</additionalClasspathElements> or <useTestClasspath>true</useTestClasspath>
<directories>
<directory>${project.build.testOutputDirectory}</directory>
</directories> |
spring-boot-maven-plugin v3.1.0
OpenJDK 20
When I put an
@SpringBootApplication
annotated class into the test foldersrc/test/java
and activateuseTestClasspath
the class cannot be loaded instart
goal.I have verified that the compiled class is present at target/test-classes/de.my. Putting the package and the class to src/main/java works.
pom.xml
The docs state in https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#goals-start-parameters-details-useTestClasspath
I would expect target/test-classes to be part of the test classpath so the classesthere should be taken into account.
The text was updated successfully, but these errors were encountered: