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

对着背影说爱祢 提交于 2019-11-26 21:58:01

问题


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{

    }

回答1:


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>



回答2:


There is flag present for same which is as below:

<checkBuildResult>true</checkBuildResult>

<!-- Set true to fail build on test failures -->
<!-- Set false to pass build on test failures -->

You need to set in the configuration tag as below:

 <configuration>
        <projectName>oasys-confirmations</projectName>
        <outputDirectory>${project.build.directory}</outputDirectory>
       <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
       <checkBuildResult>true</checkBuildResult>
</configuration>

New config:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>3.20.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>cucumber-jvm-example</projectName>
                            <!-- output directory for the generated report -->
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <!-- optional, defaults to outputDirectory if not specified -->
                            <inputDirectory>${project.build.directory}/</inputDirectory>
                            <jsonFiles>
                                <!-- supports wildcard or name pattern -->
                                <param>**/*.json</param>
                            </jsonFiles>
                            <!-- optional, defaults to outputDirectory if not specified -->
                            <classificationDirectory>${project.build.directory}/</classificationDirectory>
                            <classificationFiles>
                                <!-- supports wildcard or name pattern -->
                                <param>sample.properties</param>
                                <param>other.properties</param>
                            </classificationFiles>
                            <parallelTesting>false</parallelTesting>
                            <checkBuildResult>true</checkBuildResult>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Old Config working till 3.16.0 version:

                 <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.19.1</version>
                        <configuration>
                            <testFailureIgnore>true</testFailureIgnore>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>net.masterthought</groupId>
                        <artifactId>maven-cucumber-reporting</artifactId>
                        <version>3.16.0</version>
                        <executions>
                            <execution>
                                <id>execution</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <projectName>>cucumber-jvm-example</projectName>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                                    <checkBuildResult>true</checkBuildResult>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

NOTE If you get same problem After this configuration then
1. Run RunnerFile Normally TestNG
2. Run Pom.xml as Maven install. 3. Check target folder there is a TagName.html file open it and view the result.



来源:https://stackoverflow.com/questions/47904644/reports-are-not-generated-when-the-build-is-failed-in-maven-cucumber-reports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!