Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why my Sonar Jenkins job never becomes unstable, even with test failures?

I have a job in Jenkins that is run every night. The tasks executed during this build are: compilation, unit tests, integration tests (which are only JUnit tests which are longer than "real unit tests" to execute), and Sonar quality analysis.

When a test fails, the job is however considered as successfull and thus, no email is sent to notify this failure.

The Maven command used is mvn clean install sonar:sonar. Removing the install goal does not change anything.

What is wrong with that?

Is there a way to get the expected behavior (i.e. having an unstable build when a test failed) with only one Jenkins job, or should I create two jobs, one for the whole "Java part" (compile, unit test and integration tests), and one for the Sonar analysis?

We are using Maven 2.0.9, Java 1.6, Sonar 2.8, Jenkins 1.413.

like image 633
Romain Linsolas Avatar asked Jun 21 '11 07:06

Romain Linsolas


1 Answers

Jenkins seems to set that property: Hudson build successful with unit test failures

With the property (-Dmaven.test.failure.ignore=false), when there is a test failure, the build stops.

There is a jenkins plugin for sonar: That seems to analyze even if Tests fails: http://jira.codehaus.org/browse/SONARPLUGINS-461

In my sonar installation, I run the tests seperate from sonar and reuse the junit/surefire reports. That way I can control the tests independently from sonar.

like image 128
oers Avatar answered Oct 31 '22 20:10

oers