-
Notifications
You must be signed in to change notification settings - Fork 41.1k
SpringBootTest does not work with Java 10/modules #13581
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
Thanks for the report. Being unable to find The second problem is trying to point out that your module-info is incorrect and that you need to add
With that change in place,
As with the first problem, this is indicative of classpath scanning not working correctly. This can be confirmed by adding another test class: package hello;
import java.util.Arrays;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
public class ScanningTest {
@Test
public void scanningTest() throws Exception {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
System.out.println(Arrays.toString(resolver.getResources("classpath*:hello/**/*.class")));
}
} It produces the following output:
Note that the only classes that have been found are in The args that Surefire uses to launch the forked JVM are written to
Note that |
Thanks for getting back. I'm not clear why I should need to add |
The tests may be in the same module but Spring Framework is not. From Spring Framework's reference documentation:
|
Ok, that bit of documentation seems to imply that I need to |
Yes, Spring Framework's use of CGLib to proxy your |
I attempted to port the Spring web testing example at https://github.com/spring-guides/gs-testing-web to Java 10 and modules, however I find when running my tests via Maven that the
@SpringBootTest
annotation is no longer able to locate my application class despite the code working previously before modularisation.I receive the following error when runningmvn test
Adding the application class explicitly as this message suggests then results in
The changes I made to the initial repo can be viewed here: spring-guides/gs-testing-web@master...keirlawson:j10_modules
The text was updated successfully, but these errors were encountered: