查找多模块Maven项目的代码覆盖率 [英] Find code coverage for multi module maven project

查看:125
本文介绍了查找多模块Maven项目的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个git存储库中有一个多模块maven项目,而我的集成测试用例在另一个git存储库中.多模块maven项目的输出是三个模块的三个jar.现在有了通过命令行的一种方法(以便我们可以通过jenkins运行它)来查找另一个存储库中的集成测试的代码覆盖率.当JAR通过java -jar <<jarname>>运行时,它将使用该应用程序启动码头服务器.

I have a multi module maven project in one git repository and my integration test cases on another git repository. The output of multi module maven project is three jars for three modules. Now is there a way via command line (so that we can run this through jenkins) to find code coverage for integration tests that are in another repository. The JAR when ran through java -jar <<jarname>> it starts a jetty server with the application.

推荐答案

您可以使用JaCoCo代理执行jar来收集覆盖率数据-

You can execute your jar with JaCoCo agent to gather coverage data - http://www.jacoco.org/jacoco/trunk/doc/agent.html

并编写一个小的Ant脚本来组合类,源和coverage数据以生成报告- http://www.jacoco.org/jacoco/trunk/doc/ant.html

And write a small Ant-script to combine classes, sources and coverage data for generation of report - http://www.jacoco.org/jacoco/trunk/doc/ant.html

请注意,生成报告所需要的类与测试执行期间所使用的类完全相同-

Note that generation of report requires exact same classes that were used during execution of tests - http://www.jacoco.org/jacoco/trunk/doc/classids.html

这篇关于查找多模块Maven项目的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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