2014-03-06 3 views
4

이 코드를 실행할 때 나는 다음과 같은 오류가 발생합니다 : (ColorMatrix를 float [] 반환 getarray())JUnit을 NoClassDefFoundError를 org.junit.Assert 자체에

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

오류 :

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

하지만를 프로젝트 빌드 경로가 있습니다

enter image description here

그것은 junit.framework.TestCase를 포함 (: 편집이
이 테스트 클래스 클래스 경로 enter image description here

이 테스트중인 클래스입니다 enter image description here

답변

3

는 스택 추적은 솔루션에 대한 힌트를 포함 (그것은 라이브러리 프로젝트입니다) 그래서이 클래스는 클래스 패스에 있습니다.) 나중에는 org.junit.Assert을 찾을 수 없습니다. 당신은 클래스 패스에 3.8 JUnit을 한 것처럼 테스트하지만 JUnit 4에서는 실행시에게 그들을 컴파일

이 보인다.

단위 테스트 러너가 클래스 경로를 빌드하고 수정하는 방법을 확인하십시오.

+0

Eclipse에서 마법사를 사용하여 실제로 JUnit 테스트 플레인 바닐라를 만들었습니다. 나는 Build Path를 고치지 않았다. 단원 테스트 주자가 다른 사람보다 저와 다른 행동을해야하는 이유는 무엇입니까? 당신이 말한 내용을 확인하는 방법이 희미한 아이디어를 제외하고는 :-( – ilomambo

+0

내 생각에는 내 테스트 라이브러리에 여러 가지 테스트가 있습니다. 일부는 Junit 테스트 (JUnit4)이고 일부는 Android JUnit 테스트 (JUnit3)입니다. – ilomambo

+0

내가 테스트 한 내용은 혼합 된 테스트라고했지만 JUnit4 라이브러리는 JUnit3과 호환 될 수 있어야합니다.하지만 그렇다고해도 테스트가 'TestCase'를 확장하면 사용할 수 없습니다. (assertArrayEquals와 같이) JUnit4에 의해 도입 된 새로운 메소드는 JUnit3 제한 사항을 준수해야합니다. – ilomambo