Error

org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests

2023. 3. 14. 22:00
목차
  1. 문제
  2. 해결

문제

테스트를 작성하면서 아래와 같은 오류가 발생했다.

 

아래는 작성한 테스트이다.

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@ExtendWith(SpringExtension.class)
@WebMvcTest(controllers = HomeController.class)
public class HomeControllerTest {

    @Autowired
    private MockMvc mvc;

    @Test
    public void hello가_리턴된다() throws Exception {
        String hello = "hello";

        mvc.perform(get("/hello"))
                .andExpect(status().isOk())
                .andExpect(content().string(hello));
    }
}

 

 

build.gradle

...

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-web')
    testImplementation('org.springframework.boot:spring-boot-starter-test')

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

test {
    useJUnitPlatform()
}

 

 

해결

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'

위 두 코드를 제거했더니 문제가 해결 되었다.

https://github.com/jojoldu/freelec-springboot2-webservice/issues/585#issuecomment-818407043

 

[오류] p.63 HelloControllerTest 오류 · Issue #585 · jojoldu/freelec-springboot2-webservice

기존에 올라온 질문이 아닌지 먼저 검색해주세요! 가장 자주 나온 제보 P.105 @PutMapping("/api/v1/posts") P.111 Posts.update 어떤 오류인가요? 오류설명: HelloControllerTest 테스트 코드 실행시 Test 실패 메세지

github.com

이미 spring-boot-starter-test에 junit이 포함되어 있는데 별도로 junit을 추가해서 중복됐기 때문인 것 같다.

 

종속성을 제거하고 보니

5.8.1이 아닌 5.7.0으로 바뀌었다. 기본적으로 포함된 5.7.0이 있는데 5.8.1이 들어와 두 개가 충돌된 것 같다.

'Error' 카테고리의 다른 글

org.springframework.beans.factory.UnsatisfiedDependencyException  (0) 2023.03.28
[missing_user_info_uri] Missing required UserInfo Uri in UserInfoEndpoint for Client Registration  (0) 2023.03.16
java.sql.SQLException: No database selected  (0) 2023.03.10
[에러] Uncaught ReferenceError: $ is not defined  (0) 2022.12.04
[에러] java.lang.NumberFormatException  (0) 2022.12.03
  1. 문제
  2. 해결
'Error' 카테고리의 다른 글
  • org.springframework.beans.factory.UnsatisfiedDependencyException
  • [missing_user_info_uri] Missing required UserInfo Uri in UserInfoEndpoint for Client Registration
  • java.sql.SQLException: No database selected
  • [에러] Uncaught ReferenceError: $ is not defined
ewok
ewok
ewok
기록장
ewok
전체
오늘
어제
  • 분류 전체보기
    • 웹개발 교육
      • HTML
      • CSS
      • JavaScript
      • Database
      • Java
      • jQuery
      • Ajax
      • Bootstrap
      • jsp
      • Spring
      • MyBatis
      • 프로젝트
    • JAVA
    • SpringBoot
      • 기초
      • AWS
      • 개인프로젝트
    • Spring Security
    • JPA
    • 테스트코드
    • Error
    • CS
      • 컴퓨터 구조
      • 이산수학
    • 알고리즘
      • 정리
      • Java
    • SQL
    • 자격증
      • SQLD
      • 정보처리기사
    • Git

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • merge commit
  • this
  • sqld 합격
  • 생성자
  • sqld 자격증
  • GIT
  • 브랜치
  • git bash
  • 버전 관리
  • org.hibernate.tool.schema.spi.CommandAcceptanceException
  • base
  • org.springframework.beans.factory.UnsatisfiedDependencyException
  • 노랭이
  • SQLD
  • branch

최근 댓글

최근 글

hELLO · Designed By 정상우.
ewok
org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.