Monday, August 24, 2009

Maven gotcha: "post-integration-test" phase

In Maven, "post-integration-test" phase can be used to do test clean up, for example, to shut down Cargo after the tests finished.

If you run "maven install" then the phases would be in this order:


pre-integration-test: start Cargo (web server)
integration-test: start tests
post-integratino-test: stop Cargo


However, if you just run "maven integration-test" to run the tests directly, "post-integration-test" phase is never called, which might lead to your cleanup process not being run.

So the workaround is to bind your clean up tasks to "integration-test" itself which will be run right after the tests run during that phase.
Post a Comment