Maven surefire不会重新运行失败的测试。我尝试将surefire版本更改为3.0.0-M4,3.0.0-M5。使用命令行选项-Dsurefire。rerunFailingTestsCount=3,在pom文件中添加<surefire.rerunFailingTestsCount>了2,在surefire插件的配置中添加了2</surefire.rerunFailingTestsCount>;我运行了mvn安装多次。然而,似乎没有任何工作,Surefire只运行了一次失败的测试。我正在使用的项目的pom文件是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.authy</groupId>
<artifactId>authy-java</artifactId>
<version>1.5.1</version>
<packaging>jar</packaging>
<name>Authy Java</name>
<description>Java library to access the Authy API.</description>
<url>https://github.com/authy/authy-java</url>
<licenses>
<license>
<name>The MIT License (MIT)</name>
<url>https://github.com/authy/authy-java/blob/master/LICENSE.txt</url>
</license>
</licenses>
<developers>
<developer>
<name>Sergio Aristizabal</name>
<email>saristizabal@twilio.com</email>
<organization>Twilio</organization>
<organizationUrl>http://www.twilio.com</organizationUrl>
</developer>
</developers>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<scm>
<connection>scm:git:git@github.com:authy/authy-java.git</connection>
<developerConnection>scm:git:git@github.com:authy/authy-java.git</developerConnection>
<url>git@github.com:authy/authy-java.git</url>
</scm>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.44.v20210927</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.5.5</version>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.5.5</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20150729</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<name>Authy Maven Snapshot Repository</name>
<url>
https://oss.sonatype.org/content/repositories/snapshots/
</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<name>Authy Maven Repository</name>
<url>
https://oss.sonatype.org/service/local/staging/deploy/maven2/
</url>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<rerunFailingTestsCount>2</rerunFailingTestsCount>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration combine.self="override">
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>edu.illinois.cs</groupId>
<artifactId>testrunner-maven-plugin</artifactId>
<version>1.2</version>
<dependencies>
<dependency>
<groupId>edu.illinois.cs</groupId>
<artifactId>idflakies</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<className>edu.illinois.cs.dt.tools.detection.DetectorPlugin</className>
</configuration>
</plugin>
<plugin>
<groupId>edu.illinois</groupId>
<artifactId>nondex-maven-plugin</artifactId>
<version>1.1.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<autoVersionSubmodules>true</autoVersionSubmodules>
<useReleaseProfile>false</useReleaseProfile>
<!-- references the profile defined just below -->
<releaseProfiles>release</releaseProfiles>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<check />
</configuration>
</plugin>
</plugins>
</build>
</project>
当我尝试了很多关于stackoverflow的不同建议时,我有点不知道是什么原因导致了失败的测试被多次执行。
提前感谢!
1条答案
按热度按时间swvgeqrz1#
maven-surfire-plugin下缺少一些配置。请查看工作配置: