Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to re run failed test using jvm-cucumber-parallel-plugin

I am using jvm cucumber parallel plugin and want to re-run my failed test cases. What changes are required to make in .pom file.

  <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>
like image 858
bugCracker Avatar asked Oct 29 '22 08:10

bugCracker


1 Answers

You can try to rerun failed tests using maven-surefire-plugin like this:

<configuration>
    <rerunFailingTestsCount>3</rerunFailingTestsCount>
</configuration>

and add a plugin as following:

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

The whole .pom file would look like this:

<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>

NOTE: This feature is supported only for JUnit 4.x.

More information can be found in the official documentation here.

Also there is a custom gitHub project, which extends Cucumber options and allows to set re-run failed tests count and even conditional re-run. You can check it here:

  • GitHub project
  • documentation website

PS: you can check also answers here.

like image 117
Andrei Suvorkov Avatar answered Nov 17 '22 03:11

Andrei Suvorkov