Reports are not generated when the build is failed in Maven Cucumber Reports

Nagarjuna Reddy picture Nagarjuna Reddy · Dec 20, 2017 · Viewed 11.1k times · Source

Reports are generating successfully when the build is successful but when there are any failed cases which cause build failure, reports are not generated.

checkBuildResult is already set to false

pom file plugin

     <plugin>
        <groupId>net.masterthought</groupId>
        <artifactId>maven-cucumber-reporting</artifactId>
        <version>3.13.0</version>
        <executions>
            <execution>
                <id>execution</id>
                <phase>verify</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <projectName>Simplify360 Automation Test Report</projectName>
                    <outputDirectory>${project.build.directory}/site/cucumber-reports</outputDirectory>
                    <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                    <!-- <jsonFiles>
                        <param>${project.build.directory}/cucumber.json</param>
                    </jsonFiles> -->
                    <!-- <parallelTesting>false</parallelTesting> -->
                    <buildNumber>8.4.1.2</buildNumber>
                    <checkBuildResult>false</checkBuildResult>
                </configuration>
            </execution>
        </executions>
    </plugin>

And the runner class is as below,

  @RunWith(Cucumber.class)
    @CucumberOptions(
            features = {"classpath:features"},
            plugin = {"pretty","json:target/cucumber.json"},
            tags = {"@currentTest"},
            glue={"helpers","stepDefinitions"},
            monochrome = true
            )
    public class RunCukesTest{

    }

Answer

Murthi picture Murthi · Dec 20, 2017

Add the following configuration to the sure fire plugin. It will not stop the maven execution after the failure. Then it will generate the report.

<testFailureIgnore>true</testFailureIgnore>

as given below with your existing configuration.

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.20</version>
      <configuration>
        <testFailureIgnore>true</testFailureIgnore>
     </configuration>
</plugin>