Try to use JUnit today and download the latest JUnit version, which is 4.11. lang. noClassDefFoundError: An error such as org/hamcrest/SelfDescribing. I checked it online. The general solution is to change to a lower version. Some people say that the hamcrest package is missing. I went to the official website and looked at it again. I found the following:
Junit. jar
: Includes the Hamcrest classes. The simple all-in-one solution to get started quickly.Starting with version 4.11, Hamcrest
Is no longer encoded in this jar.
Junit-dep.jar
: Only allowed des the JUnit classes but not Hamcrest. Lets you use a different Hamcrest version.
Pay attention to the Black and underlined parts. Note: There is no hamcrest package in 4.1.1 and I don't know what the author thinks.
The best solution is:
Use is a package import solution:Junit. jar + hamcrest-core.jar + hamcrest-library.jar
Or:Junit-dep.ajr + hancrest-all.jar
Although the two import methods avoid repeated packages, they still encounter conflicts during use. After checking the various types and documents in the package, we found that some classes (such as assertions is () appear at org. hamcrest. mathchers and org. hamcrest. core, you need to pay attention when using it.