JaCoCo采用微服务项目架构? [英] JaCoCo with microservice project architecture?

查看:399
本文介绍了JaCoCo采用微服务项目架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目由java中的6个微服务组成,我试图弄清楚如何将Jacoco的html报告合并为一个总体覆盖报告。现在,我最终得到每个服务的报告,并且最好有一个汇总的报告,这样我就可以更容易地将它放入我们的CI中以获取可见性等。



我尝试了各种在网络搜索中找到的东西,但是当我尝试这些建议时,我最终得到了空白的覆盖文件。



这是我的gradle file:

 子项目{
apply插件:'jacoco'
jacoco {
toolVersion = 0.7+
reportsDir = file($ buildDir / reports / customJacocoReportDir)
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.destination$ buildDir / reports / jacocoHtml

}
测试{
由jacocoTestReport
... $完成b
$ b

我运行gradle测试来运行测试并获取每个服务的报告输出上面,但我真的很难将它们合并成一个单一的HTML报告。如果有人已经成功完成了这个工作,请告诉我。谢谢。

解决方案

目前我们遇到同样的问题,jacoco代理有一个名为merge的maven目标, 。您可以指定源文件并运行它:



jacoco:merge

/ p>

描述:

Mojo用于合并一组执行数据文件(*。

li>需要执行Maven项目。

  • 目标是线程安全的并支持并行构建。


  • b


    默认绑定到生命周期阶段:generate-resources。

     <文件集> 
    < fileSet implementation =org.apache.maven.shared.model.fileset.FileSet>
    <目录> $ {project.build.directory}< / directory>
    <包括>
    < include> *。exec< / include>
    < / includes>
    < / fileSet>
    < / fileSets>


    实际链接: http://www.eclemma.org/jacoco/trunk/doc/merge-mojo.html

    希望它有帮助:D

    My project consists of 6 microservices in java and I am trying to figure out how to merge the html reports from Jacoco into one overall coverage report. As it stands now I end up with a report for each service and it would be nice to have an aggregated one so I can more easily put it into our CI for visibility etc.

    I've tried various things I've found on web searches, but I end up with an empty coverage file when I try those suggestions.

    Here is my gradle file:

    subprojects {
    apply plugin: 'jacoco'
    jacoco {
        toolVersion = "0.7+"
        reportsDir = file("$buildDir/reports/customJacocoReportDir")
    }
    jacocoTestReport {
        reports {
            xml.enabled true
            csv.enabled false
            html.destination "$buildDir/reports/jacocoHtml"
        }
    }
    test {
    finalized by jacocoTestReport
    ...
    }
    

    I run gradle test to run the tests and get the report output per service using the above, but I am really stumped on how to merge them into a single html report. If anyone has done this successfully please let me know. Thank you.

    解决方案

    At the moment we have the same kind of problem, the jacoco agent has a maven goal called "merge". You can specify the source files and run it:

    jacoco:merge

    Full name:

    org.jacoco:jacoco-maven-plugin:0.7.8-SNAPSHOT:merge

    Description:

    Mojo for merging a set of execution data files (*.exec) into a single file

    Attributes:

    • Requires a Maven project to be executed.
    • The goal is thread-safe and supports parallel builds.
    • Since version: 0.6.4.
    • Binds by default to the lifecycle phase: generate-resources.

    <fileSets>
      <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
        <directory>${project.build.directory}</directory>
        <includes>
          <include>*.exec</include>
        </includes>
      </fileSet>
    </fileSets>
    

    Actual link: http://www.eclemma.org/jacoco/trunk/doc/merge-mojo.html

    Hope it helps :D

    这篇关于JaCoCo采用微服务项目架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆