2012-04-25 4 views
0

Junit에 속한 패키지 (내 org.junit, org.junit.experimental.results, org.junit.internal, org.junit.internal.matchers, org.junit.matchers, org.junit.rules)의 프로젝트에서 컴파일 오류가 발생했습니다.Java/Junit 4를 사용하면 컴파일 오류가 발생합니다.

이 모든 클래스는 내 프로젝트에서 다음과 같은 의미로 사용됩니다. Security/src/org.junit, Security/src/org.junit.experimental.results, 여기서 Security은 내 프로젝트의 이름입니다. 내가 쓴 내 수업은 내가 정의하는 다른 패키지 아래에 있습니다 : 모든 클래스에서 Security/src/myPackage/myClass

, 그것은 예를 들어, 가져 오기 라인에 complation 오류를 제공합니다

import org.hamcrest.Description cannot be resolved 
import org.hamcrest.Matcher cannot be resolved; 
import static org.junit.matchers.JUnitMatchers.containsString cannot be resolved; 

수표 확인합니다 (가고있다 녹색/빨간색 막대가 표시되고 올바른 결과를 제공함)이 문제는 모든 프로젝트에서 오류를 발생시킵니다.

답변

4

JUnit 버전에는 Hamcrest가 필요합니다. 빌드 경로에 포함하거나 이전 JUnit 버전을 사용해야합니다.

  • 의 JUnit-4.10.jar :

    는 릴리스 4.10의 다른 JUnit을 패키지 있습니다 Hamcrest를 포함, 당신이 사용해야합니다.

  • junit-dep-4.10.jar : Hamcrest를 포함하지 않습니다. 이미 빌드 경로에 hamcrest jar가있는 경우 이것을 사용하십시오.
+0

처음에는 junit-4.10.jar 만 가져옵니다. 그러나'import org.junit을 해결할 수 없다 ','import junit을 해결할 수 없다'라고 씁니다. 이를 위해 junit-dep-4.10.jar을 설치하면 이러한 문제를 해결할 수 있습니다. –

관련 문제