Collections:
Run org.junit.runner.JUnitCore in junit-4.*.jar
How to run org.junit.runner.JUnitCore in junit-4.*.jar?
✍: Guest
org.junit.runner.JUnitCore is the main class of the JUnit 4,
which requires hamcrest-core-1.3.jar.
If you run org.junit.runner.JUnitCore without Hamcrest, you will get a NoClassDefFoundError exception:
fyicenter> java -version java version "21.0.2" 2024-01-16 LTS fyicenter> java -cp junit-4.13.2.jar org.junit.runner.JUnitCore JUnit version 4.13.2 Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1027) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526) at org.junit.runner.Computer.getSuite(Computer.java:28) at org.junit.runner.Request.classes(Request.java:77) at org.junit.runner.JUnitCommandLineParseResult.createRequest(JUnitCommandLineParseResult.java:116) at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77) at org.junit.runner.JUnitCore.main(JUnitCore.java:36) ... 14 more
Now download hamcrest-core-1.3.jar from Maven Hamcrest Core repository.
Then org.junit.runner.JUnitCore with hamcrest-core-1.3.jar included in the class path, you will get OK message:
(On Windows) fyicenter> java -cp junit-4.13.2.jar;hamcrest-core-1.3.jar \ org.junit.runner.JUnitCore (On Linux or macOS) fyicenter> java -cp junit-4.13.2.jar:hamcrest-core-1.3.jar \ org.junit.runner.JUnitCore JUnit version 4.13.2 Time: 0.001 OK (0 tests)
The output shows that 0 tests performed, because no test class is given.
⇒ Simple Test Program for junit-4.12.*.jar
2025-04-03, ∼428🔥, 0💬
Popular Posts:
How to valid UUID/GUID strings? In order to help your programming or testing tasks, FYIcenter.com ha...
How to set Content-Type to application/json? The server requires the Content-Type to be application/...
How to generate user full names? Test user names are frequently needed in testing applications that ...
How to Pass Windows Environment Variable to JMeter? I want to use Windows temporary folder environme...
Where to find online test tools? FYIcenter.com has prepared a number of online test tools: Data Look...