IntelliJ에서 실행되지 않는 JUnit4 및 JUnit5 테스트

기쁘게 되다

IntelliJ IDEA 2017.1.5의 동일한 프로젝트에서 JUnit4 및 JUnit5 테스트를 사용하려고합니다. 지금까지 모든 테스트는 JUnit4를 기반으로했습니다. 나는 추가 jupiter, platform그리고 vintage내 pom.xml 파일에 종속합니다 (를 포함 junit-platform-surefire-provider하고 junit-vintage-engine확실한 플러그인). 이제 JUnit4에 대한 예제 테스트도 JUnit 5에 대한 테스트도 실행되지 않습니다.

대신 다음과 같은 오류가 발생합니다.

Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader;
    at org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry.loadTestEngines(ServiceLoaderTestEngineRegistry.java:30)
    at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:53)
    at com.intellij.junit5.JUnit5IdeaTestRunner.createListeners(JUnit5IdeaTestRunner.java:39)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Process finished with exit code 1
Empty test suite.

가능한 JUnit 5 사용자 가이드 의 조언을 따르려고했지만 뭔가 놓친 것 같습니다. 두 테스트를 모두 제대로 실행하려면 어떻게해야합니까? (물론 내 모든 기존 테스트)

JUnit 4 테스트 클래스

package com.glaed.util;

import org.junit.Test;

public class JUnit4Test {

  @Test
  public void helloJUnit4Test() {
    System.out.println("Hello JUnit4!");
  }

}

JUnit 5 테스트 클래스

package com.glaed.util;

import org.junit.jupiter.api.Test;

class JUnit5Test {

  @Test
  void helloJU5test() {
    System.out.println("Hello JUnit5!");
  }
}

pom.xml (관련 부분)

    <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <testSourceDirectory>src/test</testSourceDirectory>
                    <excludes>
                        <exclude>**/*WebappTest.java</exclude>
                    </excludes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.junit.platform</groupId>
                        <artifactId>junit-platform-surefire-provider</artifactId>
                        <version>1.0.0-M5</version>
                    </dependency>
                    <dependency>
                        <groupId>org.junit.jupiter</groupId>
                        <artifactId>junit-jupiter-engine</artifactId>
                        <version>5.0.0-M5</version>
                    </dependency>
                    <dependency>
                        <groupId>org.junit.vintage</groupId>
                        <artifactId>junit-vintage-engine</artifactId>
                        <version>4.12.0-M5</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencies>

    <!-- JUNIT5 & JUPITER -->

    <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.0.0-M5</version>
        <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.0.0-M5</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>4.12.0-M5</version>
        <scope>test</scope>
    </dependency>

    <!-- JUnit 4 -->

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>

</dependencies>
안슐 샤르마

다음 버전을 사용하십시오 junit-jupiter-api.

<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter-api</artifactId> 
  <version>5.0.0-M4</version>
  <scope>test</scope>
</dependency>

또한 5.0.0-M4모든 junit-jupiter종속성 에 대한 버전 사용하십시오 .

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Junit 5 및 Maven에서 실행되지 않는 테스트

기존 테스트를 JUnit4에서 Junit5로 변환하는 이유는 무엇입니까?

JUnit5 및 Spring-boot-starter-parent를 사용할 때 테스트가 실행되지 않았습니다.

JUnit5에서 지정된 순서로 테스트가 실행되지 않습니다.

다중 모듈 프로젝트에서 JUnit5 및 SpringBoot2를 사용하여 intelliJ 대신 gradle로 테스트를 실행하는 방법

Junit5 매개변수화된 테스트 수명 주기. @BeforeAll 및 정적 블록이 모든 테스트 후에 실행되는 이유

ActiveProfile는 Junit5 테스트에서 작동하지 않습니다

모든 테스트는 Intellij에서 Spring Boot 및 JUnit5와 함께 종료됩니다.

테스트 스위트는 JUnit5에서 사용되지 않는 것으로 간주하고 있는가?

JUnit4 및 Mockito에서 SQLiteOpenHelper 테스트 케이스 작성

추가 테스트 모듈을 생성하지 않고 failsafe 및 Junit5로 JPMS 서비스를 테스트하는 방법은 무엇입니까?

JUnit 5 테스트는 IntelliJ 내부 및 Maven과 로컬에서 병렬로 실행되지만 Google Cloud Build의 Maven Docker 컨테이너 내부에서는 실행되지 않습니다.

JUnit4 테스트에서 @Before 및 @After에있는 객체의 동일한 인스턴스에 액세스

JUnit5에서 실패한 테스트를 관리하는 방법

Kotlin 및 JUnit5에서 Spring Boot 캐시 테스트

Spring Boot에서 JUnit5 및 Mockito와의 통합 테스트

Android Junit4 테스트가 CircleCI 테스트 요약에 표시되지 않습니다.

@Rule 주석은 Junit5를 사용하는 spock 단위 테스트에서 고려되지 않습니다.

지정된 순서로 JUnit4 테스트 클래스 실행

JUnit Jupiter (JUnit5)에서 매개 변수화 된 테스트 실행

spock 및 junit5 테스트를 실행하도록 Maven 플러그인을 구성하는 방법

Android Studio 1.1에서 간단한 JUnit4 테스트를 실행하는 방법은 무엇입니까?

Maven 테스트는 Spring Boot 2.2 및 JUnit 5에서 Cucumber 시나리오를 실행하지 않습니다.

Junit5에서 각 테스트 케이스의 실행 시간을 기록하는 주석

메이븐은 JUnit5 테스트를 실행하지 않습니다

병렬 모드에서 정렬 된 JUnit5 테스트를 실행하는 방법

Maven을 사용하여 Eclipse에서 단일 JUnit4 테스트 실행

jupiter Junit5 플랫폼의 빈티지 엔진을 사용하여 카테고리로 JUnit4 테스트를 실행하는 Gradle로 구성하는 방법

JUnit5 : 어떻게 실패 테스트를 반복하는?

TOP 리스트

  1. 1

    Matlab의 반복 Sortino 비율

  2. 2

    ImageJ-히스토그램 빈을 변경할 때 최대, 최소 값이 변경되는 이유는 무엇입니까?

  3. 3

    Excel : 합계가 N보다 크거나 같은 상위 값 찾기

  4. 4

    C #에서 'System.DBNull'형식의 개체를 'System.String'형식으로 캐스팅 할 수 없습니다.

  5. 5

    원-사각형 충돌의 충돌 측면을 찾는 문제

  6. 6

    Oracle VirtualBox-설치를 위해 게스트를 부팅 할 때 호스트 시스템이 충돌 함

  7. 7

    어떻게 아무리 "나쁜", ANY의 SSL 인증서와 HttpClient를 사용하지합니다

  8. 8

    Ubuntu는 GUI에서 암호로 사용자를 만듭니다.

  9. 9

    잘못된 상태 예외를 발생시키는 Apache PoolingHttpClientConnectionManager

  10. 10

    Python 사전을 사용하는 동안 "ValueError : could not convert string to float :"발생

  11. 11

    openCV python을 사용하여 텍스트 문서에서 워터 마크를 제거하는 방법은 무엇입니까?

  12. 12

    Vuetify 다중 선택 구성 요소에서 클릭 한 항목의 값 가져 오기

  13. 13

    C ++ VSCode에서 같은 줄에 중괄호 서식 지정

  14. 14

    Cassandra에서 버전이 지정된 계층의 효율적인 모델링

  15. 15

    JQuery datepicker 기능이 인식되지 않거나 새 프로젝트에서 작동하지 않음

  16. 16

    cuda 11.1에서 Pytorch를 사용할 때 PyTorch가 작동하지 않음: Dataloader

  17. 17

    jfreecharts에서 x 및 y 축 선을 조정하는 방법

  18. 18

    상황에 맞는 메뉴 색상

  19. 19

    마우스 휠 JQuery 이벤트 핸들러에 대한 방향 가져 오기

  20. 20

    매개 변수에서 쿼리 객체를 선언하는 방법은 무엇입니까?

  21. 21

    Maven은 아이 프로젝트 대상 폴더를 청소하지

뜨겁다태그

보관