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
2026-03-22, ∼876🔥, 0💬
Popular Posts:
How to generate user birthday dates? Test user birthday dates are frequently needed in testing appli...
What are JMeter command line options? You can get see JMeter command line options by running this co...
Where to find tutorials on UFT (Unified Functional Testing) tool? I want to know how to use UFT. Her...
How to validate Mod 10 (Luhn Algorithm) checksum? In order to help your programming or testing tasks...
How to Override a JMeter Variable from Command Line? I want to run the same test plan multiple times...