在Maven Cucumber Reports中构建失败时,不会生成报告

问题描述 投票:2回答:2

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

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
2个回答
4
投票

将以下配置添加到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>

0
投票

有相同的旗帜,如下:

<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>
© www.soinside.com 2019 - 2024. All rights reserved.