简体   繁体   English

JaCoCo与多模块Maven项目-仅记录模块拥有的测试的覆盖率

[英]JaCoCo with multi-module Maven project - Only record coverage by module owned tests

We have a large Maven project with about 50 modules. 我们有一个包含约50个模块的大型Maven项目。 Today we have a good setup where we get a combined JaCoCo coverage for the whole project. 今天,我们有了一个很好的设置,可以在整个项目中获得JaCoCo的综合报道。 We also use the final binary generated by JaCoCo for custom coverage logic. 我们还将JaCoCo生成的最终二进制文件用于自定义覆盖率逻辑。

We would like to implement a more strict coverage policy where only tests in the same module contribute to the overall coverage. 我们希望实施更严格的覆盖率政策,其中只有同一模块中的测试有助于整体覆盖率。 We want every module to be responsible for its own tests and coverage. 我们希望每个模块负责其自身的测试和覆盖范围。

For example. 例如。 Module A depends on module B. A has code that makes use of code in B. When tests in A is run, we do not want to have coverage from any class in B recorded. 模块A依赖于模块B。A具有使用B中代码的代码。运行A中的测试时,我们不想记录B中任何类的覆盖率。

Is this setup possible? 这种设置可行吗? Trying around, I find that JaCoCo has many options for filtering when generating the final report, but I'd like to do this in the first step, when the coverage is collected. 尝试一下,我发现JaCoCo在生成最终报告时有很多过滤选项,但是我想在第一步是收集覆盖率时执行此操作。

Eventually, I'd like to end up with a JaCoCo exec file in each module's target directory that only has classes recorded from its own module. 最终,我想在每个模块的目标目录中得到一个JaCoCo exec文件,该文件仅包含从其自己的模块记录的类。 It would be perfectly fine if we had to do some configuration on a module-by-module basis like having an explicit package expression for inclusion. 如果我们必须在逐个模块的基础上进行一些配置,例如具有包含在内的显式包表达式,那将是非常好的。

Trying around, I find that JaCoCo has many options for filtering when generating the final report, but I'd like to do this in the first step, when the coverage is collected. 尝试一下,我发现JaCoCo在生成最终报告时有很多过滤选项,但是我想在第一步是收集覆盖率时执行此操作。

There is also options for filtering during collection - see includes and excludes options of JaCoCo Java Agent and corresponding options of prepare-agent in jacoco-maven-plugin . 还有在收集期间进行过滤的选项- 请参阅JaCoCo Java Agent的includesexcludes选项以及jacoco-maven-pluginprepare-agent相应选项

Build of JaCoCo itself uses them exactly for this. JaCoCo的构建本身就将其完全用于此目的。

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

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