-1

I have few runner classes say CucumberLocalTestRunner, CucumberFeatureBranchTestRunner, CucumberMasterTestRunner class . These runner classes use the extended cucumber options. I am using cucumber jvm version 4.4.0.

In the pom file I have profiles set which having one to one relation with runner classes.

How I will include the runner class in the pom file so that if I run mvn clean verify -P local then only the CucumberLocalTestRunner would run.

Secondly I am guessing extended cumber options would generate the report as consolidated after rerunning the failed tests. ( i.e I have three tests. first run:- two passed and one failed. second run:- only the failed one executed and passed . then i would see a report of all three passed.)

    <profile>
      <id>local</id>
      <properties>
       
      </properties>
    </profile>
    <profile>
      <id>master</id>
      <properties>
        
      </properties>
    </profile>
package selenium.runners;

import com.github.mkolisnyk.cucumber.runner.ExtendedCucumber;
import com.github.mkolisnyk.cucumber.runner.ExtendedCucumberOptions;
import cucumber.api.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(ExtendedCucumber.class)
@ExtendedCucumberOptions(
        jsonReport = "target/81/cucumber.json",
        jsonUsageReport = "target/81/cucumber-usage.json",
        usageReport = true,
        detailedReport = true,
        detailedAggregatedReport = true,
        overviewReport = true,
        overviewChartsReport = true,
        pdfPageSize = "A4 Landscape",
        toPDF = true,
        outputFolder = "target/81",
        retryCount = 2,
        threadsCount = 2)
@CucumberOptions(
    glue = {"selenium.stepdefs"},
    features = {"src/test/resources/features/"},
    plugin = {"json:target/cucumber/cucumber.json", "junit:target/cucumber/cucumber.xml"},
    strict = true,
    tags = "@local")
public class CucumberLocalTestRunner {}

asinha
  • 337
  • 1
  • 6
  • 24

1 Answers1

0

You want to add the runner class within your plugin like the following:

    <profiles>
        <profile>
            <id>local</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <version>2.22.2</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <includes>
                                <include>**/CucumberLocalTestRunner.java</include>
                            </includes>
                            <argLine>Xmx12g -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -Duser.timezone=Europe/London</argLine>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>net.masterthought</groupId>
                        <artifactId>maven-cucumber-reporting</artifactId>
                        <version>5.6.0</version>
                        <executions>
                            <execution>
                                <id>execution</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <projectName>Local Run</projectName>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <inputDirectory>${project.build.directory}</inputDirectory>
                                    <jsonFiles>
                                        <param>cucumber.json</param>
                                    </jsonFiles>
                                    <mergeFeaturesById>false</mergeFeaturesById>
                                    <mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
                                    <checkBuildResult>false</checkBuildResult>
                                    <buildNumber>1</buildNumber>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo message="Cucumber execution complete. Reports are available in ${project.build.directory}/cucumber-html-reports/feature-overview.html"/>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
   </profiles>

Then repeat for each profile, choosing what plugin you want to run with the other profiles etc.

djmonki
  • 3,020
  • 7
  • 18