1

My project must run java test in terminal for cicd, in fact, the project is C/C++ and I am coding Java interfaces on demo stage.

I used apt-get install junit5 to install junit on my system, and the default path is in /usr/share/java:

.rw-r--r-- root root 110.1 KB Wed Oct 25 06:03:22 2017  junit-3.8.2.jar
...
.rw-r--r-- root root  62.9 KB Sun Nov 24 08:31:45 2019  junit-platform-console-1.3.2.jar
.rw-r--r-- root root   7.4 KB Sun Nov 24 08:31:45 2019  junit-platform-console-standalone-1.3.2.jar
lrwxrwxrwx root root    43 B  Sun Nov 24 08:31:45 2019  junit-platform-console-standalone.jar ⇒ junit-platform-console-standalone-1.3.2.jar
lrwxrwxrwx root root    32 B  Sun Nov 24 08:31:45 2019  junit-platform-console.jar ⇒ junit-platform-console-1.3.2.jar
...
lrwxrwxrwx root root    15 B  Wed Oct 25 06:03:22 2017  junit.jar ⇒ junit-3.8.2.jar
...

I would like to run junit in console, so I run java -jar junit-platform-console-standalone.jar, but the output is

Error: Unable to access jarfile junit-platform-console-standalone.jar

Even if I export CLASSPATH=${CLASSPATH}:/usr/share/java.

Next step, I run java -jar /usr/share/java/junit-platform-console-standalone.jar and I get

Error: Could not find or load main class org.junit.platform.console.ConsoleLauncher
Caused by: java.lang.ClassNotFoundException: org.junit.platform.console.ConsoleLauncher

In fact, I found org.junit.platform.console.ConsoleLauncher in

❯ jar tvf junit-platform-console.jar
...
  4857 Sun Nov 24 00:31:44 CST 2019 org/junit/platform/console/ConsoleLauncher.class
...

But junit-platform-console-standalone does not find it.

Maybe a subtle env error ?? I have no idea.

Thank you very much!

0 Answers0