December 31, 2008

Skipping Cobertura Code Check when skipping tests

My Co-works and a few people online has been asking on how to skip Cobertura code check, when they are trying to do an mvn install -Dmaven.test.skip.

The default config of the cobertura-maven-plugin does not let you do that. You will get the following error

[ERROR] Project failed check. Total line coverage rate of 0.0% is below 80.0%

One way is to keep updating you pom.xml haltOnFailure for the plugin to false, that is not a long term fix. (See my cobertura-maven-plugin blog)

The following is an example of my long term fix

1. Add the following to the pom.xml (I put in my parent pom.xml)


2. Everywhere where you config the cobertura-maven-plugin do the following


To skip the unit test and the code coverage check now run the following command

mvn install -Dmaven.test.skip -Dcobertura.runtests=false

That is it... let me know if you have issues with this way of fixing the issue or if you have a better way of archiving the goal