Ошибка «TestEngine с идентификатором junit-vintage» не удалось обнаружить тесты »в Spring Boot 2.2 - PullRequest
5 голосов
/ 24 января 2020

У меня есть простое приложение, использующее Spring Boot и Junit 5:

  • При использовании Spring Boot 2.1 (например, 2.1.8 или 2.1.12) мои модульные тесты проходят гладко

  • При использовании Spring Boot 2.2 (например, 2.2.2.RELEASE или 2.3.2.RELEASE) мои модульные тесты завершаются неудачно с сообщением об ошибке

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project XXX: There are test failures.
[ERROR]
[ERROR] Please refer to D:\Projets\workspace\XXX\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] There was an error in the forked process
[ERROR] TestEngine with ID 'junit-vintage' failed to discover tests
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: There was an error in the forked process
[ERROR] TestEngine with ID 'junit-vintage' failed to discover tests
[ERROR]         at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:656)

Я использую Maven 3.6.1, JDK 1.8, JUnit 5.6.0 и платформу JUnit 1.6.0. Я исключаю зависимость от junit:junit из spring-boot-starter-test, чтобы в дереве зависимостей не осталось артефактов JUnit 4. Обратите внимание, что Spring Boot 2.2 и 2.3 используют maven-surefire-plugin 2.22.2, поэтому моя проблема не связана с регрессией maven-surefire-plugin.

Должен ли я придерживаться Spring Boot 2.1 чтобы мой модульный тест работал?

Заранее благодарим за помощь.

1 Ответ

17 голосов
/ 28 февраля 2020

Я нашел ошибку. Зависимость от spring-boot-starter-test приводит к зависимости от junit-vintage-engine. Последнее должно быть исключено:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
    </exclusions>
</dependency>
...