Junit test error: java.lang.NoClassDefFoundError: org / hamcrest / SelfDescribing

Error abnormal part:

java.lang.NoClassDefFoundError: org / hamcrest / SelfDescribing

at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)

Caused by: java.lang.ClassNotFoundException: org.hamcrest.SelfDescribing
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 22 more

junit version used: 4.12

The reason is due to: junit4.11 above do not contain HA mcrest.

 

      From the beginning of the introduction of JUnit4.4 Hamcrest framework, Hamcest provides a set of matching symbols Matcher, these characters match closer to natural language, highly readable, more flexible.

 

      Hamcrest provides a number of methods are known as the "matchmaker" in. Wherein each of the matching unit are designed to perform specific comparisons. Hamcrest scalability is very good, so you can create a custom matcher.

 

Solution: 1. reduce junit version 4.11 to 4.11 or less

     2. Introduction introduced hamcrest-core package

 

Guess you like

Origin www.cnblogs.com/YpfBolg/p/11236962.html