본문 바로가기
web/error

No matching tests found in any candidate test task

by su0a 2024. 3. 14.

1. 발생

accessToken 안에 포함된 memberId를 확인하기 위한 테스트를 실행하는 중에 발생하였다.

@Test
public void accessToken내의MemberId확인() throws Exception{
    //given
    String accessToken= "";
   
    //when
    Long memberId = authTokensGenerator.extractMemberId(accessToken);

    //then
    Assertions.assertEquals(memberId,1);

}

 

2. 코드

No matching tests found in any candidate test task

 

3. 원인

현재 SpringBoot 3.2.3 버전을 사용중이라 JUnit5가 기본으로 설정되어 있지만 JUnit4를 사용하기 위해 build.gradle에 아래와 같은 코드를 넣어주었다. 두 테스트 프레임워크 간의 문법 차이가 있어 발생하였다.

testImplementation("org.junit.vintage:junit-vintage-engine") {
    exclude group: "org.hamcrest", module: "hamcrest-core"
}

 

4. 해결

  • 클래스 어노테이션 @RunWith(SpringRunner.class) 을  @ExtendWIth(SpringExtension.class)로 교체한다.
  • import org.junit.Test 를 import org.junit.jupiter.api.Test로 변경한다
  • 테스트 클래스를 public으로 수정한다

'web > error' 카테고리의 다른 글

ECDSA signing keys must be PrivateKey instances  (0) 2024.03.14