spauny
spauny

Reputation: 5106

Sonar how to run unit test successfully

I have a project built with maven and I recently integrated Sonar... It is really easy to configure Sonar to analyze you're project but I couldn't configure it to run my project unit test also. I tried something with Jacoco but I get some Seam error and all the other tests are skipped. By the way I'm using TestNG to run tests manually.

Upvotes: 4

Views: 17041

Answers (2)

mabroukb
mabroukb

Reputation: 701

Sonar cannot run tests, it can only analyze testing reports.

You can run yourself JUnit ( using Maven or Ant for exemple ) and push reports to Sonar (try Sonar's Maven plugin for that)

or you can give yourself a build factory (try hudson for exemple) and plug it to sonar.

Upvotes: 2

Raghuram
Raghuram

Reputation: 52665

You can use the relevant Analysis Parameters of sonar to reuse the test reports from your earlier run. You would set sonar.dynamicAnalysis property to reuseReports and specify the location of the reports in sonar.jacoco.reportPath or sonar.surefire.reportPath based on how you run the tests.

By the way, mvn sonar:sonar invokes maven's test goal, which runs unit tests as part of the analysis. So ideally if your maven can run unit tests, sonar should be able to run them.

Upvotes: 4

Related Questions