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:
- Run the cucumber tests
- Generate a report (whether or not the cucumber tests fail)
- 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?