加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – 如何使用jvm-cucumber-parallel-plugin重新运行失败的测

发布时间:2020-12-16 05:37:47 所属栏目:百科 来源:网络整理
导读:我正在使用jvm黄瓜并行插件,并希望重新运行我失败的测试用例.在.pom文件中需要进行哪些更改. plugin groupIdcom.github.temyers/groupId artifactIdcucumber-jvm-parallel-plugin/artifactId version4.2.0/version executions execution idgenerateRunners/i
我正在使用jvm黄瓜并行插件,并希望重新运行我失败的测试用例.在.pom文件中需要进行哪些更改.
<plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version>4.2.0</version>
            <executions>
                <execution>
                    <id>generateRunners</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>generateRunners</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target/runner</outputDirectory>
                        <glue>
                            <package>com.xxx.stepdefs</package>
                            <package>com.xxx.cucumber.hooks</package>
                        </glue>
                        <featuresDirectory>src/test/resources/feature</featuresDirectory>
                        <cucumberOutputDir>${basedir}/target/cucumberreport/json</cucumberOutputDir>
                        <format>json</format>
                        <strict>true</strict>
                        <plugins>
                            <plugin>
                                <name>json</name>
                            </plugin>
                        </plugins>
                        <useTestNG>true</useTestNG>
                        <namingScheme>pattern</namingScheme>
                        <namingPattern>Parallel{c}TestRunner</namingPattern>
                        <parallelScheme>FEATURE</parallelScheme>

                    </configuration>
                </execution>
            </executions>
        </plugin>
您可以尝试使用maven-surefire-plugin重新运行失败的测试,如下所示:
<configuration>
    <rerunFailingTestsCount>3</rerunFailingTestsCount>
</configuration>

并添加如下插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.21.0</version>
</plugin>

整个.pom文件看起来像这样:

<plugin>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>4.2.0</version>
    <executions>
        <execution>
            <id>generateRunners</id>
            <phase>generate-test-sources</phase>
            <goals>
                <goal>generateRunners</goal>
            </goals>
            <configuration>
                <outputDirectory>${basedir}/target/runner</outputDirectory>
                <glue>
                    <package>com.xxx.stepdefs</package>
                    <package>com.xxx.cucumber.hooks</package>
                </glue>
                <featuresDirectory>src/test/resources/feature</featuresDirectory>
                <cucumberOutputDir>${basedir}/target/cucumberreport/json</cucumberOutputDir>
                <format>json</format>
                <strict>true</strict>
                <plugins>
                    <plugin>
                        <name>json</name>
                    </plugin>
                </plugins>
                <useTestNG>true</useTestNG>
                <namingScheme>pattern</namingScheme>
                <namingPattern>Parallel{c}TestRunner</namingPattern>
                <parallelScheme>FEATURE</parallelScheme>

            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20.1</version>
    <configuration>
        <surefire.rerunFailingTestsCount>3</surefire.rerunFailingTestsCount>
    </configuration>
</plugin>

注意:仅JUnit 4.x支持此功能.

更多信息可以在官方文档here中找到.

还有一个自定义gitHub项目,它扩展了Cucumber选项,允许设置重新运行失败的测试计数甚至条件重新运行.你可以在这里查看:

> GitHub project
>文件website

PS:你也可以查看答案here.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读