小编Wol*_*ade的帖子

Maven Surefire插件没有重新运行失败的Cucumber测试

我正在使用Selenium WebDriver(版本2.53.0)的Java实现来针对Web应用程序运行一些自动化测试.使用Cucumber的Java实现(版本1.2.3)以行为驱动测试格式编写测试.我使用Maven(版本3.3.9)导入所有依赖项,并构建和运行测试.使用Cucumber标签将测试组织成不同的类别.例如,我可以使用以下命令从命令行运行用@JohnnyBravo标记的一类测试:

cd path_to_Maven_POM_file
mvn clean test -Dcucumber.options="--tags @JohnnyBravo"
Run Code Online (Sandbox Code Playgroud)

在做了一些研究之后,我发现你可以使用Maven SureFire插件通过-Dsurefire.rerunFailingTestsCount=2在上面的Maven命令中根据此链接添加" "来重新运行失败的测试.然后,我尝试使用下面的命令重新运行该类测试,同时确保其中一些肯定会失败,以便查看它们是否会重新运行:

mvn clean test -Dcucumber.options="--tags @JohnnyBravo" -Dsurefire.rerunFailingTestsCount=2
Run Code Online (Sandbox Code Playgroud)

不幸的是,失败的测试没有重新运行.我在这做错了什么?

我的POM文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         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.company</groupId>
    <artifactId>regression-test</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <properties>
        <cucumber.version>1.2.3</cucumber.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.8.2</version>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.jtds</groupId>
            <artifactId>jtds</artifactId>
            <version>1.3.1</version>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${cucumber.version}</version>
        </dependency> …
Run Code Online (Sandbox Code Playgroud)

java command-line maven-surefire-plugin selenium-webdriver cucumber-java

8
推荐指数
1
解决办法
753
查看次数