当黄瓜测试失败时,Jenkins 构建失败

时间:2021-02-09 18:06:16

标签: jenkins cucumber

我有一个包含 Cucumber 测试的测试套件。我使用“cucumber-jvm-parallel-plugin”在 Jenkins 上并行运行这些测试。除了特定场景外,一切正常 - 当所有测试失败时,构建结果显示为成功。我的 pom 文件看起来像

    <profile>
        <id>default</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>1.${java.version}</source>
                        <target>1.${java.version}</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>net.masterthought</groupId>
                    <artifactId>maven-cucumber-reporting</artifactId>
                    <version>5.0.0</version>
                    <executions>
                        <execution>
                            <id>execution</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <projectName>Project 01</projectName>
                                <skip>false</skip>
                                <!--<parallelTesting>true</parallelTesting> -->
                                <outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
                                <inputDirectory>${project.build.directory}/cucumber-parallel</inputDirectory>
                                <jsonFiles>
                                    <param>**/*.json</param>
                                </jsonFiles>
                                <checkBuildResult>true</checkBuildResult>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>com.github.temyers</groupId>
                    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                    <version>5.0.0</version>
                    <executions>
                        <execution>
                            <id>generateRunners</id>
                            <phase>generate-test-sources</phase>
                            <goals>
                                <goal>generateRunners</goal>
                            </goals>
                            <configuration>
                                <glue>
                                    <package>com.packagename</package>
                                </glue>
                                <outputDirectory>${project.build.directory}/generated-test-sources/cucumber
                                </outputDirectory>
                                <featuresDirectory>src/test/resources/${featureDirectory}</featuresDirectory>
                                <cucumberOutputDir>${project.build.directory}/cucumber-parallel
                                </cucumberOutputDir>
                                <namingPattern>Parallel{c}IT</namingPattern>
                                <parallelScheme>FEATURE</parallelScheme>
                                <tags>
                                    <tag>${parallelTag}</tag>
                                    <tag>~@Skip</tag>
                                </tags>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.22.2</version>
                    <executions>
                        <execution>
                            <id>acceptance-test</id>
                            <phase>integration-test</phase>
                            <goals>
                                <goal>integration-test</goal>
                            </goals>
                            <configuration>
                                <forkCount>6</forkCount>
                                <reuseForks>true</reuseForks>
                                <includes>
                                    <include>**/*IT.class</include>
                                </includes>
                            </configuration>
                        </execution>
                        <execution>
                            <phase>verify</phase>
                            <goals>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

Maven 执行命令:mvn clean -DfailIfNoTests=false -DfeatureDirectory= -DparallelTag=$parallelTag -P 默认验证

当所有测试都失败时,有没有办法让构建失败?

0 个答案:

没有答案