Correct maven pom configuration for Cucumber Tests and maven-cucumber-reporting

匿名 (未验证) 提交于 2019-12-03 01:41:02

问题:

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

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.

I want to:

  1. Run the cucumber tests
  2. Generate a report (whether or not the cucumber tests fail)
  3. Fail a build after generating reports if failed

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?

Update 1:

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> 

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?

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

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:

I've successfully used format = {"pretty", "html:target/Destination"} in the runner, as per the example at Tutorialspoint



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