Maven 故障安全插件不执行测试
Maven failsafe plugin not executing tests
出于调试目的,我尝试包括所有测试,但故障保护仍然只选择一个测试 (ChangePriorityTest)。所有测试都在正确的目标目录中成功编译。
pom.xml
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>at.test</groupId>
<artifactId>citest</artifactId>
<version>${revision}</version>
<name>citest</name>
<description>Test project to improve our CI pipeline</description>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<!-- Plugins -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>all-tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<skip.unit.tests>false</skip.unit.tests>
<skip.integration.tests>false</skip.integration.tests>
</properties>
</profile>
<profile>
<id>unit-tests</id>
<properties>
<skip.unit.tests>false</skip.unit.tests>
<skip.integration.tests>true</skip.integration.tests>
</properties>
</profile>
<profile>
<id>integration-tests</id>
<properties>
<skip.unit.tests>true</skip.unit.tests>
<skip.integration.tests>false</skip.integration.tests>
</properties>
</profile>
</profiles>
<reporting>
<plugins>
<!-- Unit test report -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.22.2</version>
<configuration>
</configuration>
</plugin>
</plugins>
</reporting>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application.properties</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skip.unit.tests}</skipTests>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skipTests>${skip.integration.tests}</skipTests>
<includes>
<include>**/*</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
目录结构:
- src
|- test
|-- java
|--- at/test/citest
|---- domain/model/todo
|----- ChangePriorityTest
|---- interfaces/rest/todo
|----- TodoRestDocumentation
|---- TestIntegrationTest
我尝试降级版本,包括通过 **/*
进行的所有测试。
我是不是漏掉了什么?
我通过使用 JUnit 4 而不是 5 并将两个 JUnit 5 依赖项(junit-jupiter-engine 和 junit-jupiter-api)替换为 JUnit 4 来修复它。
还是不知道问题出在哪里...
出于调试目的,我尝试包括所有测试,但故障保护仍然只选择一个测试 (ChangePriorityTest)。所有测试都在正确的目标目录中成功编译。
pom.xml
<project>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>at.test</groupId>
<artifactId>citest</artifactId>
<version>${revision}</version>
<name>citest</name>
<description>Test project to improve our CI pipeline</description>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<!-- Plugins -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>all-tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<skip.unit.tests>false</skip.unit.tests>
<skip.integration.tests>false</skip.integration.tests>
</properties>
</profile>
<profile>
<id>unit-tests</id>
<properties>
<skip.unit.tests>false</skip.unit.tests>
<skip.integration.tests>true</skip.integration.tests>
</properties>
</profile>
<profile>
<id>integration-tests</id>
<properties>
<skip.unit.tests>true</skip.unit.tests>
<skip.integration.tests>false</skip.integration.tests>
</properties>
</profile>
</profiles>
<reporting>
<plugins>
<!-- Unit test report -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.22.2</version>
<configuration>
</configuration>
</plugin>
</plugins>
</reporting>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>application.properties</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skip.unit.tests}</skipTests>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skipTests>${skip.integration.tests}</skipTests>
<includes>
<include>**/*</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
目录结构:
- src
|- test
|-- java
|--- at/test/citest
|---- domain/model/todo
|----- ChangePriorityTest
|---- interfaces/rest/todo
|----- TodoRestDocumentation
|---- TestIntegrationTest
我尝试降级版本,包括通过 **/*
进行的所有测试。
我是不是漏掉了什么?
我通过使用 JUnit 4 而不是 5 并将两个 JUnit 5 依赖项(junit-jupiter-engine 和 junit-jupiter-api)替换为 JUnit 4 来修复它。
还是不知道问题出在哪里...