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

Support modular test project #807

Closed
jimliuxyz opened this issue Sep 16, 2019 · 7 comments · Fixed by #836
Closed

Support modular test project #807

jimliuxyz opened this issue Sep 16, 2019 · 7 comments · Fixed by #836
Milestone

Comments

@jimliuxyz
Copy link

The test always fails when using "module-info.java", but mvn test works fine. it took me hours to find the cause, seems no one has this problem, can anyone help me?

9月 16, 2019 4:49:14 下午 org.junit.platform.launcher.core.DefaultLauncher handleThrowable
WARNING: TestEngine with ID 'junit-vintage' failed to discover tests
org.junit.platform.commons.PreconditionViolationException: Could not load class with name: com.tester.EmptyServiceTest
	at org.junit.platform.engine.discovery.MethodSelector.lambda$lazyLoadJavaClass$0(MethodSelector.java:157)
	at org.junit.platform.commons.function.Try$Failure.getOrThrow(Try.java:335)
	at org.junit.platform.engine.discovery.MethodSelector.lazyLoadJavaClass(MethodSelector.java:156)
	at org.junit.platform.engine.discovery.MethodSelector.getJavaClass(MethodSelector.java:135)
	at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:34)
	at org.junit.vintage.engine.discovery.MethodSelectorResolver.lambda$resolve$0(MethodSelectorResolver.java:30)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.junit.vintage.engine.discovery.MethodSelectorResolver.resolve(MethodSelectorResolver.java:30)
	at org.junit.vintage.engine.discovery.VintageDiscoverer.collectTestClasses(VintageDiscoverer.java:64)
	at org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:51)
	at org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:61)
	at org.junit.platform.launcher.core.DefaultLauncher.discoverEngineRoot(DefaultLauncher.java:168)
	at org.junit.platform.launcher.core.DefaultLauncher.discoverRoot(DefaultLauncher.java:155)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
	at com.microsoft.java.test.runner.junit5.CustomizedConsoleTestExecutor.lambda$executeTests$0(CustomizedConsoleTestExecutor.java:42)
	at com.microsoft.java.test.runner.junit5.CustomContextClassLoaderExecutor.invoke(CustomContextClassLoaderExecutor.java:29)
	at com.microsoft.java.test.runner.junit5.CustomizedConsoleTestExecutor.executeTests(CustomizedConsoleTestExecutor.java:38)
	at com.microsoft.java.test.runner.junit5.CustomizedConsoleLauncher.execute(CustomizedConsoleLauncher.java:29)
	at com.microsoft.java.test.runner.Launcher.main(Launcher.java:56)
Caused by: java.lang.ClassNotFoundException: com.tester.EmptyServiceTest
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
	at org.junit.platform.commons.util.ReflectionUtils.lambda$tryToLoadClass$9(ReflectionUtils.java:779)
	at org.junit.platform.commons.function.Try.lambda$call$0(Try.java:57)
	at org.junit.platform.commons.function.Try.of(Try.java:93)
	at org.junit.platform.commons.function.Try.call(Try.java:57)
	at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:742)
	at org.junit.platform.commons.util.ReflectionUtils.tryToLoadClass(ReflectionUtils.java:698)
	... 17 more

github source

@jdneo jdneo added the bug label Sep 16, 2019
@jdneo
Copy link
Member

jdneo commented Sep 16, 2019

@jimliuxyz Thanks for reporting this. The root cause is that currently the test runner does not support module path yet. We will try to resolve this ASAP.

@jdneo jdneo changed the title "failed to discover tests" when using "module-info.java" Support module for JUnit tests Oct 15, 2019
@jdneo
Copy link
Member

jdneo commented Oct 16, 2019

Fixed in #836. This fix also relies on microsoft/java-debug#304 to get released.

@jdneo jdneo changed the title Support module for JUnit tests Support modular test project Oct 16, 2019
@jdneo jdneo added this to the 0.20.1 milestone Oct 16, 2019
@jdneo jdneo added enhancement and removed bug labels Oct 16, 2019
@lingocoder
Copy link

„...seems no one has this problem...“

@jimliuxyz I ran into the same problem while recently testing a Gradle plugin I'm developing. The same test that works fine in Eclipse, results in a ClassNotFoundException in vscode.

@jdneo Thank you so much for fixing this! Do you have a rough ETA for when we can expect the fix you implemented in #836 to be available? TIA 👍

@jdneo
Copy link
Member

jdneo commented Oct 28, 2019

Hi @lingocoder, the ETA could be before the end of this week. Hopefully I will release it around this Thursday.

@lingocoder
Copy link

Hi jdneo,

Thanks for the release! I was waiting for it with much excitement :)

I'm having a hard time getting a test in this modular project to work in 0.21.0 though...

vscode-java-test issues 807 a 2
vscode-java-test issues 807 a 0
vscode-java-test issues 807 a 1

I just today upgraded vscode to 1.39.2...

Version: 1.39.2 (system setup)
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:35:10.237Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT ia32 6.1.7601

...and also updated Debugger for Java to 0.23.0.

Anything obvious jump out at you that I'm probably doing wrong? TIA.

@jdneo
Copy link
Member

jdneo commented Nov 1, 2019

@lingocoder let me take a look and will respond to you later

@jdneo
Copy link
Member

jdneo commented Nov 1, 2019

@lingocoder I does not meet the problem you have met. Maybe you can try to reload your window to try it again.

But, I met another problem Class not found com.company.LibraryTest, which can also be repro in Eclipse. Meanwhile, if I create a main method in the class LibraryTest it cannot run either. So I guess there is something wrong when calculate the classpath for gradle project.

Besides, the project can run correctly in IntelliJ.

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

Successfully merging a pull request may close this issue.

3 participants