Integration testing with maven and jetty
While working on my gsoc project i came across a situation where i had to test a servlet while it is deployed within a servlet container. The requirement is simple; make some requests to the servlet and check whether the servlet responds correctly. After some googling i finally figured out how to put the pieces together in just two easy steps:
Configure jetty to start execution just before the “integration-test” phase and stop when all integration tests are run:
org.mortbay.jetty jetty-maven-plugin 7.0.0pre1 /xwiki-webdav 0 stop 9999 start-jetty pre-integration-test run 0 true stop-jetty post-integration-test stop
Configure surefire tests so that integration tests are separated from usual unit tests:
org.apache.maven.plugins maven-surefire-plugin **/*TTest.java surefire-it integration-test test **/*ITest.java
That’s it, now simply execute `mvn integration-test`