4

None of the plugins in the reporting section of Maven execute if there is a unit test failure.

I found that I can set maven.test.failure.ignore=true here - http://jira.codehaus.org/browse/SUREFIRE-247 The problem to this approach is now our hudson builds are successful even if there are unit test failures.

What I would really like to do is set the reporting plugin maven-surefire-report-plugin to run with the build plugins on a phase but I can't get this to work.

Any idea on how to get the Maven reporting plugins to execute if a unit test failure occurs?

5 Answers5

2

Firstly run: mvn test OR mvn install. Then, if the tests fail, please run the following target to generate the reports for the test results executed above: mvn -Dmaven.test.skip=true surefire-report:report

djm.im
  • 3,295
  • 4
  • 30
  • 45
  • That would work but I am not sure how to do that within a hudson CI build. Any suggestion on how to do that? Thanks for your help! – Vincen Collins Nov 15 '10 at 16:59
  • Try to create two Hudson jobs in such a way that they point to one workspace of project. in first job try to run mvn test OR mvn install and in the other job just execute mvn -Dmaven.test.skip=true surefire-report:report (dont run mvn clean in the second job) – Pushpinder Rattan Nov 26 '10 at 11:40
1

In the link you posted:

With the latest version (2.1.2), I get a message saying that "There are some test failure," but I get no reports anywhere whether or not I specify that variable, or whether or not I specify "testFailureIgnore" in the plugin config. I got the reports fine with 2.0, but not with 2.1.2.

Do you need version 2,1 or can you work with a 2.0 version of Maven?

Peter Schuetze
  • 16,185
  • 4
  • 44
  • 58
1

The error you see with 2.1.2 is because of forkmode settings which you need to perform in the plugin.

set forkmode=never and try it (I susppect there might problem in your useSystemclassloader property).

Otherwise make use of maven-surefire plugin version 2.5 which should definitel work and generate surefire rpeorts even though few test fails.

  • The issue I am encountering is in the maven-surefire-report-plugin. I am actually using the maven-surefire-report-plugin to create a report from the surefire reports created by flexMojos. Maybe that is a detail that I should have included but I don't see how maven-surefire-report-plugin should be dependent on the behavior in the maven-surefire-plugin. – Vincen Collins Oct 25 '10 at 18:27
  • Firstly run : mvn test OR mvn install Then, if the tests fail,please run following target to generate the reports for the test results executed above: mvn -Dmaven.test.skip=true surefire-report:report – Pushpinder Rattan Nov 06 '10 at 12:58
1

Please make use of surefire-report:report-only plugin if the reports are already generated after execution.

  • So I am running 'mvn install surefire-report:report-only' but the surefire-report plugin never runs once a unit test failure occurs during the install goal (same issue) – Vincen Collins Nov 04 '10 at 21:39
0

I had the same issue and it is due to a wrong call to the report plugin.

The correct execution of maven command is: mvn surefire-report:report

This will run the test phase by itself and if it fails it will generate the report anyway.

Check the documentation: http://maven.apache.org/surefire/maven-surefire-report-plugin/report-mojo.html

Hope this helps!! :D

user1336321
  • 144
  • 1
  • 1
  • 10