-
TestEngine with ID 'junit-jupiter' failed to discover tests 에러카테고리 없음 2024. 1. 5. 23:37
Junit5 버전으로 테스트 코드를 실행하는 과정에서 다음과 같은 에러가 발생
Internal Error occurred. org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests ... Caused by: java.lang.NoClassDefFoundError: org/junit/jupiter/api/io/CleanupMode ... 8 more Caused by: java.lang.ClassNotFoundException: org.junit.jupiter.api.io.CleanupMode ... 10 more
프로젝트 설정은 JDK17 / Kotiln / Maven 으로 구성하였고
IntelliJ UI를 통하여 설정한 부분이라 이후 자세하게 확인했다.
원인은 라이브러리 버전 충돌 문제였는데
kotiln-test-junit은 junit-jupiter-engine 5.6.3에 의존하지만
프로젝트가 만들어질 때 자동으로 junit-jupiter-engine 5.10.0도 같이 선언하면서
두 버전이 충돌이 났고, 그로 인하여 NoClassDefFoundError 가 발생했다.
중복되는 라이브러리 중 하나를 지워줌으로 써 해결하였다.
<dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-test-junit5</artifactId> <version>1.9.0</version> <scope>test</scope> </dependency> <!-- 5.10.0 버전 제거 --> <!-- <dependency> --> <!-- <groupId>org.junit.jupiter</groupId>--> <!-- <artifactId>junit-jupiter-engine</artifactId>--> <!-- <version>5.10.0</version>--> <!-- <scope>test</scope>--> <!-- </dependency>--> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.9.0</version> </dependency> </dependencies>