Java org.JUnit.Assert本身上的JUnit NoClassDefFoundError

Java org.JUnit.Assert本身上的JUnit NoClassDefFoundError,java,junit,junit4,assertions,Java,Junit,Junit4,Assertions,运行此代码时出现以下错误:(ColorMatrixgetarray()返回浮点值[]) 错误: ----- begin exception ----- java.lang.NoClassDefFoundError: org.junit.Assert at com.Common.lib.test.ColorFilterFactoryTest.testHueShift(ColorFilterFactoryTest.java:77) at java.lang.reflect.Met

运行此代码时出现以下错误:(ColorMatrix
getarray()
返回浮点值[])

错误:

 ----- begin exception -----
 java.lang.NoClassDefFoundError: org.junit.Assert
    at com.Common.lib.test.ColorFilterFactoryTest.testHueShift(ColorFilterFactoryTest.java:77)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
    at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)
    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)
 ----- end exception -----
但项目构建路径有:

编辑
这是测试类类路径

这是被测试的类(它是一个库项目)

堆栈跟踪包含解决方案的提示:它包含
junit.framework.TestCase
(因此该类位于类路径上),但稍后,它找不到
org.junit.Assert

这看起来好像在运行测试时类路径上有JUnit 3.8,但在编译它们时有JUnit 4


了解单元测试运行程序是如何构建类路径的,并在那里进行修复。

我实际上在Eclipse中使用向导创建了JUnit测试。我没有修改构建路径。为什么单元测试运行者对我的行为与其他人不同?除此之外,我一点也不知道如何检查你所说的:-(你确实给了我一个想法,我的测试库有混合测试——一些是Junit测试(JUnit4),一些是Android Junit测试(JUnit3)所以这可能是问题的根源。我想我已经解决了,正如我说的,我有混合测试,但是JUnit4库应该向后兼容JUnit3。但即使如此,如果您的测试扩展了
TestCase
,您也不能利用JUnit4引入的新方法(比如
assertArrayEquals
)您必须遵守JUnit3限制。如果两个JAR都在类路径上,那么如果第一个JAR不正确,就会发生奇怪的事情。您可以使用
Assert.assertarayequals()在JUnit3测试中使用JUnit4代码
如果因为它选择JUnit 3的
断言而不起作用,那么创建一个helper类来包装您想要使用的方法。我试图做得更好并重新创建失败,但没有成功。发布的图片确实是工作案例。我认为在此之前添加的库(如Xerces和JUnit4)位于底部,Android依赖项和私有库位于顶部。
 ----- begin exception -----
 java.lang.NoClassDefFoundError: org.junit.Assert
    at com.Common.lib.test.ColorFilterFactoryTest.testHueShift(ColorFilterFactoryTest.java:77)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at junit.framework.TestCase.runTest(TestCase.java:154)
    at junit.framework.TestCase.runBare(TestCase.java:127)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
    at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)
    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)
 ----- end exception -----