Reputation: 1092
I run my cucumber tests by using mvn integration-test
. If my test directory contains test which ends with Error parsing feature file
, my next tests do not run at all.
I've got 4 .feature files, one of them contain invalid step (not parsed). If I remove that step, I have a successfull run for 4 files (Tests run: 23, Failures: 2, Errors: 0, Skipped: 3
),
if I don't, I've got the following message: Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.078 sec <<< FAILURE!
. I want maven to continue testing after 1 invalid feature file, not to stop on the first one, so I need something like Tests run: 24, Failures: 2, Errors: 1, Skipped: 3
(my unparseable step is the last one)
Fragment of my pom.xml:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<cucumber.options>${cucumber.options}</cucumber.options>
</systemPropertyVariables>
</configuration>
</plugin>
Question: How can I make maven continue with other cucumber features after the error?
Upvotes: 0
Views: 2053
Reputation: 27812
You cannot skip only parsings errors, there is no knowledge of the type of error for the test execution.
However, based on your experience you may get a certain number of acceptable failures (to keep testing till the end your test suite or till a certain acceptable failures rate) using the skipAfterFailureCount
option of the maven-failsafe-plugin
(the maven-surefire-plugin
has the same option in case you are using it).
Alternatively, and with a more strong approach, you may set the Maven build to ignore failures during tests and keep on testing the whole suite by using the testFailureIgnore
of the maven-failsafe-plugin
for its verify
goal or the same option for the maven-surefire-plugin
.
If you don't want to configure them in your pom.xml
as default build, you could delegate this behavior to a maven profile or use their respective command line options:
mvn clean verify -Dmaven.test.failure.ignore=true
Or (to use the first option above)
mvn clean verify -Dsurefire.skipAfterFailureCount=42
Or (depending on the plugin you used)
mvn clean verify -Dfailsafe.skipAfterFailureCount=12
Note that I used verify
and not integration-test
as a phase because integration tests are supposed to set-up and tear down a context/env to integrate against, to properly execute integration tests in this case you should:
maven-failsafe-plugin
and not the maven-surefire-plugin
pre-integration-test,
integration-testand
post-integration-test` to properly set-up, execute, clean your integration test phaseUpvotes: 2