【问题标题】:Reports are not generated when the build is failed in Maven Cucumber ReportsMaven Cucumber Reports 中构建失败时不生成报告
【发布时间】:2018-06-02 22:21:32
【问题描述】:

构建成功时报告生成成功,但是当有任何导致构建失败的失败案例时,不会生成报告。

checkBuildResult 已设置为 false

pom 文件插件

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

跑步者类如下,

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

    }

【问题讨论】:

    标签: maven selenium selenium-webdriver cucumber cucumber-jvm


    【解决方案1】:

    将以下配置添加到sure fire插件。它不会在失败后停止 maven 执行。然后它会生成报告。

    <testFailureIgnore>true</testFailureIgnore>
    

    如下所示,使用您现有的配置。

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

    【讨论】:

    【解决方案2】:

    存在相同的标志,如下所示:

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

    您需要在配置标签中进行如下设置:

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

    新配置:

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

    旧配置工作到 3.16.0 版本:

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

    注意如果您在此配置后遇到同样的问题,那么
    1. 正常运行RunnerFile TestNG
    2. 运行 Pom.xml 作为 Maven 安装。 3.检查目标文件夹是否有TagName.html文件打开查看结果。

    【讨论】:

    • @ShubhamJain 它仅在执行“maven 安装”时生成 html 报告,仅生成 json 报告并且在作为 TestNG 测试运行时不更新 Html 报告。有什么想法吗?
    猜你喜欢
    • 2016-05-14
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    • 2022-10-18
    相关资源
    最近更新 更多