正确的maven pom配置以进行黄瓜测试和maven-cucumber报告 [英] Correct maven pom configuration for Cucumber Tests and maven-cucumber-reporting

查看:302
本文介绍了正确的maven pom配置以进行黄瓜测试和maven-cucumber报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经在以前的项目中工作过,但现在找不到了...

I had this working in a previous project but cannot find it now...

我正在使用Maven来构建Java应用程序,并且在构建过程中要在该应用程序上运行测试.我正在使用 maven-cucumber-reporting 插件v3.0.0来汇总结果报告.

I am using Maven to build a java app and I am running tests on the app during the build process. I am using maven-cucumber-reporting plugin v3.0.0 to put together a report of the outcome.

我要:

  1. 运行黄瓜测试
  2. 生成报告(黄瓜测试是否失败)
  3. 如果生成报告失败,则构建失败

如何使用 maven-surefire-plugin maven-cucumber-reporting 插件以及任何其他插件来组合我的pom?

How can I setup my pom with a combo of maven-surefire-plugin, maven-cucumber-reporting plugin, and any other plugins to make this work?

更新1:

这是我当前的pom配置:

Here is my current pom 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>${cucumber.reporting.version}</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <projectName>${project.artifactId}</projectName>
                        <outputDirectory>${project.basedir}/src/test/report/cucumber-reports</outputDirectory>
                        <cucumberOutput>${project.basedir}/src/test/report/cucumber.json</cucumberOutput>
                        <skippedFails>true</skippedFails>
                        <enableFlashCharts>false</enableFlashCharts>
                        <buildNumber>${project.version}</buildNumber>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>com.coderplus.maven.plugins</groupId>
            <artifactId>copy-rename-maven-plugin</artifactId>
            <version>1.0</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <id>copy-file</id>
                    <phase>test</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <sourceFile>${project.basedir}/src/test/report/cucumber.json</sourceFile>
                        <destinationFile>${project.parent.basedir}/src/test/report/cucumber-${project.artifactId}-${project.version}.json</destinationFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>

如何使黄瓜测试在maven-surefire-plugin期间运行,而在maven-cucumber-reportingcopy-rename-maven-plugin插件运行以生成我的报告并将其放置在正确的位置(多模块pom我正在聚合的位置)之前,它不会失败在父级进行测试),然后失败了吗?

How can I get the cucumber tests to run during maven-surefire-plugin, not fail before the maven-cucumber-reporting and copy-rename-maven-plugin plugins run to generate my reports and put them in the right place (multi-module pom where I am aggregating tests at parent), AND THEN fail the build?

当前条件1和2通过(我的Cucumber测试运行,失败,然后生成了报告,但是构建没有失败).

Currently conditions 1 and 2 pass (my Cucumber tests run, fail, and then reports are generated, but the build does NOT fail).

也许更笼统地说,如何在Maven构建中运行测试,然后执行一些报告插件,然后在报告插件运行之后使构建失败?

Maybe more generically, how can I run tests as part of a maven build, then execute some reporting plugins, then fail the build after the reporting plugins run?

推荐答案

按照 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆