我有一个叫做Customer的java项目,在这个下面我有另外8个模块,其中有5个模块有junit测试类,每个模块都有单独的ant构建文件。我为每个项目创建了(生成的单元测试报告)jacoco.exec,现在,我想将这5个模块的单元测试报告合并为一个报告,并显示(或)显示sona覆盖部分中每个模块的单元测试报告。你能提供任何建议吗?多个java单元测试报告的声纳覆盖报告
感谢, 约瑟夫
我有一个叫做Customer的java项目,在这个下面我有另外8个模块,其中有5个模块有junit测试类,每个模块都有单独的ant构建文件。我为每个项目创建了(生成的单元测试报告)jacoco.exec,现在,我想将这5个模块的单元测试报告合并为一个报告,并显示(或)显示sona覆盖部分中每个模块的单元测试报告。你能提供任何建议吗?多个java单元测试报告的声纳覆盖报告
感谢, 约瑟夫
你想要做的是阅读每个模块的测试报告什么。您可以使用多模块项目配置来完成此任务。如果您从主build.xml中处理所有内容,它可能是最直接的。我没有从蚂蚁测试这一点,但这样的事情应该工作
<property name="sonar.projectKey" ...
<!-- all normal properties here -->
<property name="sonar.modules" value="module1,module2..." />
<property name="module1.sonar.jacoco.reportPath" value="...
注意,如果Jacoco的报告是在一个标准的位置,你甚至可能不需要,因为子模块继承父母指定它们属性。 The docs多模块项目配置中没有考虑到的Ant语法编写的,但你应该可以,只要通过工作,因为你记住这一点从SonarQube Scanner for Ant docs:
The SonarQube Scanner for Ant is an Ant Task that is wrapper of SonarQube Scanner, which works by invoking SonarQube Scanner and passing to it all properties named following a
sonar.*
convention. This has the downside of not being very Ant-y, but the upside of providing instant availability of any new analysis parameter introduced by a new version of a plugin or of SonarQube itself.
非常感谢。再次向Ann ..它适用于我,解决了我的问题(涵盖和每个模块的多种语言)后添加sonar-project.properties中的每个子项目单独的模块,如下所述..获得'覆盖'结果模块在Sonarqube ..
# Modules
sonar.modules=common,help,mobile,partners
common.sonar.projectBaseDir=C:/dev/workspaces/hg/customer
common.sonar.sources=common/src/main/java,common/web
common.sonar.tests=common/src/test/java
common.sonar.binaries=common/bin
common.sonar.junit.reportsPath=common/test/reports/junitreport
common.sonar.surefire.reportsPath=common/test/reports/junitreport
common.sonar.jacoco.reportPath=common/coverage/common.exec
help.sonar.projectBaseDir=C:/dev/workspaces/hg/customer
help.sonar.sources=help/src/main/java,help/web
help.sonar.tests=help/src/test/java
help.sonar.binaries=help/bin
help.sonar.junit.reportsPath=help/test/reports/junitreport
help.sonar.surefire.reportsPath=help/test/reports/junitreport
help.sonar.jacoco.reportPath=help/coverage/help.exec
如果您在顶层指定属性,则不会必须为每个模块覆盖它们:https://github.com/SonarSource/sonar-examples/blob/master/projects/multi-module/sonar-runner/java-sonar-runner-modules-different-structures/sonar- project.properties – jondro
这为我工作:
sonar.modules=common,help
sonar.sources=./src/main/java
sonar.binaries=./target/classes
sonar.tests=./src/test/java
sonar.junit.reportsPath=./target/surefire-reports
的路径应该是相对的,因为声纳自动导航到BASEDIR/MODULE_NAME /目标/万无一失的报告
非常感谢安,我将尝试这种方法,你在上面提到的“module1.sonar”。 jacco.reportPath“等等... –
现在,我遇到了这个错误,而我在詹金斯运行声纳运行我的项目,错误:导致:无法加载组件类org.sonar.batch.repository.ProjectRepositories 错误:由http:// localhost:9000/batch/project.protobuf?key = aimia-java-sonar-runner上的错误500引起的: –
您可能最好将其转到Google组:https://groups.google .com /论坛/#!论坛/ sonarqube –