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
292 stars 125 forks source link

Tests in the Plugin Tests project fail #1624

Closed DelusionalLogic closed 10 months ago

DelusionalLogic commented 10 months ago

Hey,

It looks like commit 26188a9eda2d7b7345648d06bbe5c13c3096e793 has caused a regression that breaks the build. I got the commit by bisecting. This is the relevant part of the build log.

[INFO] --- tycho-surefire-plugin:2.7.2:test (default-test) @ com.microsoft.java.test.plugin.test ---
[INFO] Could not find a java toolchain of type jdk and JAVA_HOME is not set, trying java from PATH instead
[INFO] Executing Test Runtime with timeout 0, logs (if any) will be placed at: /home/delusional/.local/share/jdtls/vscode-java-test/java-extension/com.microsoft.java.test.plugin.test/target/work/data/.metadata/.log
[INFO] Command line:
    [java, -Dosgi.noShutdown=false, -Dosgi.os=linux, -Dosgi.ws=gtk, -Dosgi.arch=x86_64, -Dosgi.clean=true, -jar, /home/delusional/.m2/repository/p2/osgi/bundle/org.eclipse.equinox.launcher/1.6.400.v20210924-0641/org.eclipse.equinox.launcher-1.6.400.v20210924-0641.jar, -data, /home/delusional/.local/share/jdtls/vscode-java-test/java-extension/com.microsoft.java.test.plugin.test/target/work/data, -install, /home/delusional/.local/share/jdtls/vscode-java-test/java-extension/com.microsoft.java.test.plugin.test/target/work, -configuration, /home/delusional/.local/share/jdtls/vscode-java-test/java-extension/com.microsoft.java.test.plugin.test/target/work/configuration, -application, org.eclipse.tycho.surefire.osgibooter.headlesstest, -testproperties, /home/delusional/.local/share/jdtls/vscode-java-test/java-extension/com.microsoft.java.test.plugin.test/target/surefire.properties]
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Running com.microsoft.java.test.plugin.launchers.JUnitLaunchConfigurationDelegateTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.229 s <<< FAILURE! - in com.microsoft.java.test.plugin.launchers.JUnitLaunchConfigurationDelegateTest
testWorkingDirectoryForTestNgUnmanagedFolder(com.microsoft.java.test.plugin.launchers.JUnitLaunchConfigurationDelegateTest)  Time elapsed: 0.972 s  <<< ERROR!
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
Caused by: java.lang.IllegalStateException: Internal problem occurred, please report it. Mockito is unable to load the default implementation of class that is a part of Mockito distribution. Failed to load interface org.mockito.plugins.MockMaker
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.mockito.exceptions.base.MockitoInitializationException:

Could not initialize inline Byte Buddy mock maker.

It appears as if your JDK does not supply a working agent attachment mechanism.
Java               : 17
JVM vendor name    : Oracle Corporation
JVM vendor version : 17.0.8.1+1
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 17.0.8.1+1
JVM info           : mixed mode
OS name            : Linux
OS version         : 6.5.6-arch2-1

Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process

Results:

Errors:
  JUnitLaunchConfigurationDelegateTest>AbstractProjectsManagerBasedTest.initProjectManager:77 » IllegalState

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Test Runner for Java :: Parent ..................... SUCCESS [  0.035 s]
[INFO] Test Runner for Java :: Build Tools ................ SUCCESS [  0.288 s]
[INFO] Test Runner for Java :: Plugin ..................... SUCCESS [  2.669 s]
[INFO] Test Runner for Java :: Plugin Tests ............... FAILURE [  4.238 s]
[INFO] Test Runner for Java :: update site ................ SKIPPED
[INFO] Test Runner for Java :: Target Platform ............ SKIPPED
[INFO] Test Runner for Java :: Runner ..................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

I'm open to provide more details, but I don't know what you'd need.

jdneo commented 10 months ago

Hmm..

I haven't a Linux machine. But on my Mac and Windows, the build has no problem.

The CI builds run successfully as well on all three platforms: https://github.com/microsoft/vscode-java-test/actions/runs/6452491660

DelusionalLogic commented 10 months ago

I didn't have the jdk correctly installed. I don't understand why how it was working in the older revision, but I'm satisfied that it's my bad.

Thanks a bunch for looking into it, and sorry for wasting your time :)

jdneo commented 10 months ago

Hi @DelusionalLogic, would you mind sharing the 'correct' JDK you have installed to fix the issue? In case other people meet this problem, that might help :)

Thank you!

DelusionalLogic commented 10 months ago

It was literally just any JDK. I had installed the 17 JRE, not the JDK. A complete blunder. I don't understand how it was even able to compile with that, but it must have been something with how arch linux packages java.

I started off downloading Zulu (what you use on CI), and when that worked I started to examine why. Turns out I had just installed jre17-openjdk instead of jdk17-openjdk from the arch repo.

Again, really sorry for wasting your time.

jdneo commented 10 months ago

Thank you for sharing :)