Java.lang.noclassdeffounderror:org/hamcrest/selfdescribing Problem resolution using JUnit Unit tests __junit Unit test

Source: Internet
Author: User

when you use JUnit for unit testing, you suddenly receive the following error:

Java.lang.noclassdeffounderror:org/hamcrest/selfdescribing at Java.lang.ClassLoader.defineClass1 (Native method) a T Java.lang.ClassLoader.defineClassCond (classloader.java:631) at Java.lang.ClassLoader.defineClass ( classloader.java:615) at Java.security.SecureClassLoader.defineClass (secureclassloader.java:141) at Java.net.URLCl Assloader.defineclass (urlclassloader.java:283) at java.net.urlclassloader.access$000 (URLClassLoader.java:58) at Ja Va.net.urlclassloader$1.run (urlclassloader.java:197) at Java.security.AccessController.doPrivileged (Native method ) at Java.net.URLClassLoader.findClass (urlclassloader.java:190) at Java.lang.ClassLoader.loadClass (Classloader.jav a:306) at Sun.misc.launcher$appclassloader.loadclass (launcher.java:301) at Java.lang.ClassLoader.loadClass (Classlo ader.java:247) at Org.junit.internal.builders.JUnit4Builder.runnerForClass (junit4builder.java:10) at Org.junit.run Ners.model.RunnerBuilder.safeRunnerForClass (Runnerbuilder.java:59) at Org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass ( alldefaultpossibilitiesbuilder.java:26) at Org.junit.runners.model.RunnerBuilder.safeRunnerForClass ( runnerbuilder.java:59) at Org.junit.internal.requests.ClassRequest.getRunner (classrequest.java:26) at Com.intellij . Junit4. Junit4ideatestrunner.startrunnerwithargs (junit4ideatestrunner.java:44) at Com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart (junitstarter.java:195) at Com.intellij.rt.execution.junit.JUnitStarter.main (junitstarter.java:63) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method) at Sun.reflect.NativeMethodAccessorImpl.invoke ( nativemethodaccessorimpl.java:39) at Com.intellij.rt.execution.application.AppMain.main (appmain.java:120) caused By:java.lang.ClassNotFoundException:org.hamcrest.SelfDescribing at Java.net.urlclassloader$1.run ( urlclassloader.java:202) at java.security.AccessController.doPrivileged (Native method in Java.net.URLClassLoader.findClass (urlclassloader.java:190) at Java.lang.ClassLoader.loadClass (Classl oader.java:306) at Sun.misc.launcher$appclassloader.loadclass (launcher.java:301) at Java.lang.ClassLoader.loadClas S (classloader.java:247) ... More
The reason for the error is that the Hamcrest-core-*.jar package is missing from the JUnit jar package used, download the jar package, import the project, and the problem will be solved naturally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.