Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Cobertura and Package without running Unit Tests Twice

I am running maven like this:

mvn clean cobertura:cobertura package

I am noticing that my unit tests get run twice (thus doubling my build time). Is there a way to run cobertura AND generate the package in the same command without running tests twice?

like image 382
hofan41 Avatar asked Oct 21 '14 21:10

hofan41


1 Answers

An easy way would be to run two separate commands. In Bash it's then easy to chain them together into one line:

mvn clean cobertura:cobertura && mvn package -Dmaven.test.skip=true

The first bit:

mvn clean cobertura:cobertura

Does clean, runs the tests and generates the coverage report.

The second bit:

mvn package -Dmaven.test.skip=true

Does the packaging, but tells it not to run the tests.

The && is there so that if the first command fails, then it won't try to run the second.

like image 185
John Montgomery Avatar answered Nov 16 '22 02:11

John Montgomery