Vscode-java-test: Support modular test project

Created on 16 Sep 2019  ·  7Comments  ·  Source: microsoft/vscode-java-test

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

enhancement

Most helpful comment

@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.

All 7 comments

@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.

Fixed in #836. This fix also relies on https://github.com/microsoft/java-debug/pull/304 to get released.

„...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 :+1:

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

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.

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

@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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thegabriele97 picture thegabriele97  ·  8Comments

NikolasKomonen picture NikolasKomonen  ·  3Comments

lashchev picture lashchev  ·  5Comments

mccreery picture mccreery  ·  4Comments

mweirauch picture mweirauch  ·  8Comments