microsoft / vscode-java-test

Run and debug Java test cases in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test
Other
297 stars 132 forks source link

VS Code in the browser: Test Runner fails to run the first time, but runs fine the second time #1650

Closed firasm closed 10 months ago

firasm commented 10 months ago

Hello,

My colleagues and I are trying to use the "Test Runner for Java" extension in a workspace using VS Code in the browser (specifically the code-server project).

We are trying to troubleshoot a really strange issue that only shows up in the cloud, and not when trying to run things locally.

Here is a very very simple Java project that when it's run in the browser, gives a Class not found model.SampleTest error.

Screenshot 2024-01-18 at 8 56 46 PM

However, when you do nothing else except just run the test one more time, it works just fine:

Screenshot 2024-01-18 at 8 57 03 PM

This happens for every project that's run in the cloud this way, so we are nearly 100% sure that it's got something to do with being execute remotely. The stack trace seems useful, but it's not something that gives me any insight so I thought I'd post here to ask for help in troubleshooting!

Class not found model.ProjectInNeedTest
java.lang.ClassNotFoundException: model.ProjectInNeedTest
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
BuiltinClassLoader.java:581
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
ClassLoaders.java:178
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:527)
ClassLoader.java:527
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:766)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:490)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:513)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

I'll be cross-posting this in the code-server project to get some more eyes on it...

jdneo commented 10 months ago

What if you run it in GitHub Codespaces, will the same error happens for the first test execution?

firasm commented 10 months ago

I just tried it - and no, I cannot reproduce it in GitHub Codespaces, it runs fine the first time.

Screenshot 2024-01-18 at 11 32 57 PM

I assume this means the issue is likely somewhere in code-server configuration?

jdneo commented 10 months ago

I'm not familiar with Code Server, seems like yes.

Maybe some filesystem issue that the .class file is not discovered? I dont know...

firasm commented 10 months ago

Fair enough - I'll close this for now and hope someone there can help. Thanks for the fast reply!