简体   繁体   English

声纳如何成功运行单元测试

[英]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.我有一个用 maven 构建的项目,我最近集成了声纳......配置声纳来分析你的项目真的很容易,但我也无法配置它来运行我的项目单元测试。 I tried something with Jacoco but I get some Seam error and all the other tests are skipped.我用 Jacoco 尝试了一些东西,但我得到了一些 Seam 错误,并且所有其他测试都被跳过了。 By the way I'm using TestNG to run tests manually.顺便说一句,我正在使用 TestNG 手动运行测试。

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.您可以将sonar.dynamicAnalysis属性设置为重新使用报告, sonar.surefire.reportPath根据您运行测试的方式在sonar.jacoco.reportPathreuseReports中指定报告的位置。

By the way, mvn sonar:sonar invokes maven's test goal, which runs unit tests as part of the analysis.顺便说一句, mvn sonar:sonar调用了 maven 的test目标,它运行单元测试作为分析的一部分。 So ideally if your maven can run unit tests, sonar should be able to run them.因此,理想情况下,如果您的 maven 可以运行单元测试,那么声纳应该能够运行它们。

Sonar cannot run tests, it can only analyze testing reports. Sonar 不能运行测试,它只能分析测试报告。

You can run yourself JUnit ( using Maven or Ant for exemple ) and push reports to Sonar (try Sonar's Maven plugin for that) 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 .或者您可以给自己一个构建工厂(以hudson为例)并将其插入sonar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM