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, ∼1239🔥, 0💬
Popular Posts:
How to generate currency test values? Currency test values are frequently needed in testing date and...
How to generate ISBN numbers? To help you to obtain some ISBN numbers for testing purpose, FYIcenter...
How to turn on Chrome WebDriver logging with Selenium Python API? If you want to turn on logging on ...
How to turn on Chrome WebDriver logging with Selenium Python API? If you want to turn on logging on ...
How to generate MAC addresses? To help you to obtain some MAC addresses for testing purpose, FYIcent...