Suppose I want to create and use an H2 database for my integration tests.
Maven has a command to run tests: mvn test
.
Is there a way to tell maven t
you can create 2 small classes with main methods that start and stop the database. the idea is to run the StartServer class before the integration tests are run and then class StopServer after the tests have run.
you should do the same for your DB server as described somewhere in this document (description is for starting and stopping Jetty in integration tests)
in your pom.xml you should define the maven-exec-plugin to run the exec:java goal and create 2 executions (1 for calling StartServer and 1 for StopServer):
org.codehaus.mojo
exec-maven-plugin
1.1.1
start
pre-integration-test
java
com.foo.StartServer
stop
post-integration-test
java
com.foo.StopServer
hope that's what you want