[Junit] Method or class mismatch 에러와 initializationError 해결 방법

권용환·2021년 10월 27일
0

트러블슈팅

목록 보기
1/3

Method or class mismatch 에러

Intellij에서 Junit 사용 시, 테스트는 성공하지만 콘솔 창에 이런 에러가 발생하는 경우가 있다

org.junit.platform.launcher.core.EngineDiscoveryOrchestrator lambda$logTestDescriptorExclusionReasons$7

INFO: 0 containers and 2 tests were Method or class mismatch

이는 Gradle로 콘솔에서 빌드하고 콘솔하면서 발생하는 문제인데 gradle 자체의 문제인 것 같다

해결하기 위해서는 Settings - Build, Execution, Deployment - Build Tools - Gradle 에서 Gradle projects 내부의 Build and run usingRun tests using 을 디폴트 값인 Gradle이 아니라 Intellij IDEA로 변경하면 된다

게다가 Intellij IDEA 콘솔을 이용하면 좀 더 빠르게 실행되는 것 같은 기분이 든다!

initializationError

에러

다음 그림과 같이 Junit Vintage 관련해서 initializationError가 나는 경우도 있다

org.junit.runners.model.InvalidTestClassError: Invalid test class 'businesscardprogram.repository.JpaMemberRepositoryTest':
  1. No runnable methods

다음과 같은 에러가 뜨는 문제는 import 구문을 변경해주면 된다

@Test를 import 해줄때 import org.junit.jupiter.api.Test;이 아닌 import org.junit.Test;을 사용해주면 된다

profile
마구 낙서하는 블로그입니다

0개의 댓글

Powered by GraphCDN, the GraphQL CDN