junit - Stop tests execution after first error/failure with maven surefire -
this question has answer here:
i'm using maven surefire plugin execute junit tests of application.
i want stop execution after first failure or error. in case, these integration tests modify application state, need know exact system state after failure (we're having strange issue test passes if executed isolated, not if executed whole suite).
is possible? couldn't find option in plugin docs here.
actually, turns out not possible maven-surefire-plugin.
i found answer here.
i end using solution proposed there @mhaller
so implemented junit listener this:
package br.com.xpto; import org.junit.runner.description; import org.junit.runner.notification.failure; import org.junit.runner.notification.runlistener; import br.com.caelum.brutal.integration.scene.acceptancetestbase; public class failfastlistener extends runlistener { public void testfailure(failure failure) throws exception { system.err.println("failure: " + failure); acceptancetestbase.close(); system.exit(-1); } @override public void testfinished(description description) throws exception { acceptancetestbase.close(); system.exit(-1); } }
and configure maven-surefire this:
<plugin> <artifactid>maven-surefire-plugin</artifactid> <version>2.10</version> <executions> <execution> <id>surefire-integration</id> <phase>integration-test</phase> <goals> <goal>test</goal> </goals> <configuration> <excludes> <exclude>none</exclude> </excludes> <includes> <include>**/scene/**/*test.java</include> </includes> <forkmode>once</forkmode> <properties> <property> <name>listener</name> <value>br.com.caelum.brutal.integration.util.failfastlistener</value> </property> </properties> </configuration> </execution> </executions> <configuration> <excludes> <exclude>**/*</exclude> </excludes> </configuration> </plugin>
Comments
Post a Comment