I should have blogged about this long ago, as I feel that this is a very useful way of debugging unit tests with maven. This is especially so if you’re primarily a command line sort of guy like myself.
All that is required to be able to debug a unit test is
- configure the maven surefire plugin from within a profile
- activate the maven profile from the command line
The following XML profiles section will work just peachy for you.
dtest false org.apache.maven.plugins maven-surefire-plugin 2.5 once true
Now just run this.
mvn -Pdtest package