当前位置:   article > 正文

Jmock测试出错java.lang.NoClassDefFoundError: org/hamcrest/TypeSafeMatcher

java.lang.noclassdeffounderror: org/hamcrest/typesafematcher
错误提示如下。这是因为junit4自带了一个Hamcrest jar,将maven dependency中[color=blue]Jmock放在Junit之前[/color]解决该问题。
java.lang.NoClassDefFoundError: org/hamcrest/TypeSafeMatcher	at java.lang.ClassLoader.defineClass1(Native Method)	at java.lang.ClassLoader.defineClass(Unknown Source)	at java.security.SecureClassLoader.defineClass(Unknown Source)	at java.net.URLClassLoader.defineClass(Unknown Source)	at java.net.URLClassLoader.access$100(Unknown Source)	at java.net.URLClassLoader$1.run(Unknown Source)	at java.net.URLClassLoader$1.run(Unknown Source)	at java.security.AccessController.doPrivileged(Native Method)	at java.net.URLClassLoader.findClass(Unknown Source)	at java.lang.ClassLoader.loadClass(Unknown Source)	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)	at java.lang.ClassLoader.loadClass(Unknown Source)	at org.jmock.internal.InvocationExpectation.setMethod(InvocationExpectation.java:45)	at org.jmock.internal.InvocationExpectationBuilder.createExpectationFrom(InvocationExpectationBuilder.java:85)	at org.jmock.internal.InvocationToExpectationTranslator.invoke(InvocationToExpectationTranslator.java:19)	at org.jmock.internal.FakeObjectMethods.invoke(FakeObjectMethods.java:38)	at org.jmock.lib.JavaReflectionImposteriser$1.invoke(JavaReflectionImposteriser.java:33)	at com.sun.proxy.$Proxy1.receive(Unknown Source)	at com.jesse.dict.jmock.PublisherTest$1.<init>(PublisherTest.java:18)	at com.jesse.dict.jmock.PublisherTest.testOneSubscriberReceiveAMsg(PublisherTest.java:17)	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)	at java.lang.reflect.Method.invoke(Unknown Source)	at junit.framework.TestCase.runTest(TestCase.java:168)	at junit.framework.TestCase.runBare(TestCase.java:134)	at junit.framework.TestResult$1.protect(TestResult.java:110)	at junit.framework.TestResult.runProtected(TestResult.java:128)	at junit.framework.TestResult.run(TestResult.java:113)	at junit.framework.TestCase.run(TestCase.java:124)	at junit.framework.TestSuite.runTest(TestSuite.java:243)	at junit.framework.TestSuite.run(TestSuite.java:238)	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Caused by: java.lang.ClassNotFoundException: org.hamcrest.TypeSafeMatcher	at java.net.URLClassLoader$1.run(Unknown Source)	at java.net.URLClassLoader$1.run(Unknown Source)	at java.security.AccessController.doPrivileged(Native Method)	at java.net.URLClassLoader.findClass(Unknown Source)	at java.lang.ClassLoader.loadClass(Unknown Source)	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)	at java.lang.ClassLoader.loadClass(Unknown Source)	... 39 more
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/274453
推荐阅读
相关标签
  

闽ICP备14008679号