Question

I get the following error when running this code: (ColorMatrix getarray() returns a float[])

74 public void testHueShift() {
75     ColorMatrix cm1 = new ColorMatrix();
76     ColorMatrix cm2 = hueShift(0f);
77     assertArrayEquals(cm1.getArray(), cm2.getArray(), 0f);
78 }

the error:

 ----- 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 -----

But the project build path has it:

enter image description here

EDIT
This is the Test class classpath enter image description here

This is the class under test (It is a library project) enter image description here

Was it helpful?

Solution

The stack trace contains the hint for the solution: It contains junit.framework.TestCase (so this class is on the classpath) but later, it can't find org.junit.Assert.

This looks as if you have JUnit 3.8 on the classpath when running the test but JUnit 4 when you compile them.

Find out how the unit test runner builds the classpath and fix it there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top