I have a Dropwizard application and I am trying to create unit tests for testing the application.
I read through a bunch of resources and I am now using DropwizardTestRule to kickstart the application and run some unit tests. I also have a custom config-test.yml that I use to point the application to my local database to run the queries against.
And the Dropwizard version we are using is 0.9.2. That is unfortunately a constraint that cannot be changed at the moment.
The problem I have is running migrations on the DB before the test suite runs.
The issue is:
mvn package
runs unit tests as part of the packaging task.- Unit tests need that migrations be run as a pre-requisite.
- Running migrations need the jar created by
mvn package
as a pre-requisite.
This seems like a cyclic dependency to me that can be resolved only by first calling mvn package -DskipTests=true
which leads to the jar
creation. Then running the migrations. Then running the tests as a separate maven task.
This means my build will now have to be a script of commands. Is there a better way of doing this? Or is this the only hack?
How do I tell Dropwizard to run the migrations before running the test suite?