java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing java java

java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing


According to the JUnit GitHub team website (https://github.com/junit-team/junit/wiki/Download-and-Install), junit.jar and hamcrest-core.jar are both needed in the classpath when using JUnit 4.11.

Here is the Maven dependency block for including junit and hamcrest.

<dependency>    <groupId>junit</groupId>    <artifactId>junit</artifactId>    <version>4.1.2</version>    <scope>test</scope></dependency><!-- Needed by junit --><dependency>    <groupId>org.hamcrest</groupId>    <artifactId>hamcrest-all</artifactId>    <version>1.3</version>    <scope>test</scope></dependency>


A few steps you have to follow:

  1. Right click on the project.
  2. Choose Build Path Then from its menu choose Add Libraries.
  3. Choose JUnit then click Next.
  4. Choose JUnit4 then Finish.