Jenkins Surefire Report Show Failure - maven

I am running tests via Jenkins and Maven using surefire-report:report goal. Even when some tests fail, Jenkins displays the Job as successful due to correct completion of the job. The Surefire Reports are correct corresponding to the test results. Are there any ideas how to configure Jenkins to run and report the tests properly?
Thanks in advance!

Related

Running a certain test last using maven

I am using Maven and the failsafe plugin to execute a set of runners that run integration tests.
One of these runners execute tests that involve altering my configuration. For this reason, I would like this runner to be executed only when the other tests have finished executing. Otherwise, there is the possibility of unrepresentative tests.
How can I go about this?
To expand on #khmarbaise comment, in Testng you have annotations that can help you set and reset config files
http://testng.org/doc/documentation-main.html#annotations

Fail Jenkins job only if there is an error/issue with the job

I have a Jenkins job which runs certain SoapUI test cases using the maven plugin.The Jenkins build fails even if one of the test cases fail.I do not want this to be the case and want the job to fail only when there is an issue with the job(like it terminates in between due to some exception) or if the server is down.How can I do that?
Have you tried to skip test cases in your Maven run? Use the code below in maven properties section of maven plugin:
maven.test.failure.ignore=true

When does SonarQube plugin run unit test?

I'm using SonarQube4.2 with jekins plugin. I configured Sonar as Post-Build Action on Jenkins, and It's work fine. I'm wondering that if maven compiles test sources before executing the sonar action, sonar automatically run these test units, but maven only compiles main sources, then sonar doesn't run unit tests. If Jenkins execute mvn test phase before Sonar as Post=Build Action, Jenkins duplicate running unit tests. I want to compile sources, running unit tests and executing Sonar, hence I configured mvn test-compile with Post-Build Action for Sonar in Job. Is it usual way? Does any body knows better way to executiong sonar with Jenkins.
Regards

How do I stop sonar running tests?

I'm looking at using Sonar to reduced the number of plugins I've had to install in Jenkins to get some decent code analysis (and sonar seems to do more and present it better). However when I kick of the sonar job the JUnit / Concordion tests are executed. I don't want these tests run as Jenkins is already executing the tests.
How do I stop the tests executing and just perform code analysis?
I've installed sonar 3.7.3 and executing using the Gradle sonar-runner plugin and specifying the :sonarRunner task.
I'm just facing the same issue and it seems that you can run :sonarqube -x test to avoid having tests run before.
You can set the sonar.dynamicAnalysis property to false. This will skip tests and only perform the static analysis part.
See http://docs.codehaus.org/display/SONAR/Analysis+Parameters#AnalysisParameters-OptionalParameters

Setting up jasmine-maven-plugin failures to make jenkins unstable

I'd like to configure jasmine-maven-plugin to make jenkins unstable if a test fails but the only options appear to be:
set haltOnFailure true and have failures break the build
set haltOnFailure false and have failures reported in the logs but the build succeeds.
Is there a way to check the logs post-test and mark the build unstable?
Sam Hasler's answer only works for freestyle Jenkins jobs. We use Maven jobs and this configuration option of the JUnit Jenkins plugin is unavailable for Maven jobs. So I was looking for a more universal solution.
What we did in order to get it working is to reconfigure the Jasmine Maven plugin so as to
no longer halt the build upon test failures and
write the Jasmine test reports to target/surefire-reports where Jenkins expects to find them. This has the additional advantage that we now also see the failed Jasmine test in the build job alongside our Java tests.
<haltOnFailure>false</haltOnFailure>
<jasmineTargetDir>${project.build.directory}/surefire-reports</jasmineTargetDir>
Now our build jobs are yellow (unstable) as expected, no longer red (failed).
Found the answer myself!
I had to configure jenkins to also look at the jasmine junit report:
under Publish JUnit test result report add **/TEST-jasmine.xml to Test report XMLs, comma separated if there is something there already:
**/TESTS-TestSuites.xml,**/TEST-jasmine.xml

Resources