junit으로 테스트를 진행하던 중 아래와 같은 import 에러가 발생했습니다
해당 프로젝트는 junit3로 테스트를 진행하라고 알려줬지만 해당 라이브러리와
Build Path -> Configure Build Path
Libraries에서 JUnit3을 확인했지만 문제가 없었습니다
답은 "org.junit.jupiter"는 JUnit5 라이브러리에서 제공하는 기능으로
해당 라이브러리를 Maven에 추가해야 합니다
junit-jupiter-api 5.7.0
mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api/5.7.0
junit-jupiter-engine 5.7.0
mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine/5.7.0
작성 기준 유저들이 많이 사용한 버전으로 maven에 추가했습니다
코드
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
위 코드를 추가 후에 프로젝트 우클릭 -> 메이븐 클린 -> 메이븐 업데이트 순으로 진행하면
The import org.junit.jupiter cannot be resoloved error 사라진 것을 확인할 수 있습니다
AssertionFailedError: No tests found 더보기
주의사항

AssertionFailedError: No tests found error의 경우
테스트 메서드의 경우 이름은 항상 "test" 시작해야 한다
@Test
public void testMyExample() throws Exception {
//Test Code
}
참고
stackoverflow.com/questions/51046506/how-to-fix-the-import-org-junit-jupiter
'JAVA' 카테고리의 다른 글
[Tomcat]톰캣 8.5 버전 다운로드 및 설치 (0) | 2021.01.25 |
---|