double unit test reporting with hudson and maven

2019-03-27 08:01发布

问题:

I have a maven2 project in hudson and when the cobertura reporting plugin runs, it causes the unit tests to show that they have run twice. I don't mind them running multiple times, but the trend graph shows twice as many tests as we actually are running. Is there a way to make sure the graph only shows them once?

thanks,

Jeff

回答1:

This is a known bug. Just wait for it to be fixed.



回答2:

The workaround I use (works in Hudson 1.391) is to configure cobertura in separate Maven profile and run it in a Hudson job as a post-build step.

Mode detailed instructions:

  1. Add cobertura to your project pom in a special profile (so it won't run while default lifecycle) and configure it to create report in xml format.
  2. Install "Hudson M2 Extra Steps Plugin"
  3. Configure your Hudson job as Maven 2 project
  4. In your job configuration in the "Build" section configure usual clean/install goals
  5. In "Build Environment" section select "Configure M2 Extra Build Steps" and add Maven post-build step. Configure it to run "cobertura:cobertura -P your_cobertura_profile_name"
  6. In "Post-build Actions" select "Publish Cobertura Coverage Report" and configure proper xml report pattern (default should work just fine)


回答3:

I had the same problem recently when I was running maven goals test and emma:emma on the same job. emma seems to have rerun all tests thus doubling the results. When I removed goal test my unit tests still got executed but test results went back to normal. Could be the same with cobertura.