我需要在不同的阶段运行我的测试组(首先运行组A,然后运行组B,就像刚刚开始运行测试一样)
所以我决定使用maven-failsafe-plugin和junit测试类别的组合
我有以下配置:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>${skipTests}</skip>
<includes>
<include>**/*IT.java</include>
</includes>
<groups>my.categories.IntegrationTest</groups>
<excludedGroups>my.categories.ProfiledIntegrationTest, my.categories.MvcTest, my.categories.ExchangeRateTest</excludedGroups>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>${skipTests}</skip>
<includes>
<include>**/*IT.java</include>
</includes>
<groups>my.categories.ProfiledIntegrationTest</groups>
<excludedGroups>my.categories.IntegrationTest, my.categories.MvcTest, my.categories.ExchangeRateTest</excludedGroups>
</configuration>
<executions>
<execution>
<id>profiled-integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>${skipTests}</skip>
<includes>
<include>**/*IT.java</include>
</includes>
<groups>my.categories.MvcTest</groups>
<excludedGroups>my.categories.ProfiledIntegrationTest, my.categories.IntegrationTest, my.categories.ExchangeRateTest</excludedGroups>
</configuration>
<executions>
<execution>
<id>mvc-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>${skipTests}</skip>
<includes>
<include>**/*IT.java</include>
</includes>
<groups>my.categories.ExchangeRateTest</groups>
<excludedGroups>my.categories.MvcTest, my.categories.ProfiledIntegrationTest, my.categories.IntegrationTest</excludedGroups>
</configuration>
<executions>
<execution>
<id>exchange-rate-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
然而,maven运行我的单元测试(surefire),然后是maven故障安全插件的最后一个实例(它忽略了之前的3个)
我怎么能让它运行呢?
答案 0 :(得分:0)
解决方案如JF Meier所述
您只需拥有该插件的一个实例,并将其作为单独执行运行
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>${skipTests}</skip>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<groups>my.categories.IntegrationTest</groups>
<excludedGroups>my.categories.ProfiledIntegrationTest, my.categories.MvcTest, my.categories.ExchangeRateTest</excludedGroups>
</configuration>
</execution>
<execution>
<id>profiled-integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<groups>my.categories.ProfiledIntegrationTest</groups>
<excludedGroups>my.categories.IntegrationTest, my.categories.MvcTest, my.categories.ExchangeRateTest</excludedGroups>
</configuration>
</execution>
<execution>
<id>mvc-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<groups>my.categories.MvcTest</groups>
<excludedGroups>my.categories.ProfiledIntegrationTest, my.categories.IntegrationTest, my.categories.ExchangeRateTest</excludedGroups>
</configuration>
</execution>
<execution>
<id>exchange-rate-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<groups>my.categories.ExchangeRateTest</groups>
<excludedGroups>my.categories.MvcTest, my.categories.ProfiledIntegrationTest, my.categories.IntegrationTest</excludedGroups>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>