1

我的代码覆盖率有问题(Sonar + JaCoCo + Maven + Selenium(集成测试))。这是我的项目结构。

+-[CLIENT] 
|  +-[src]
|      +-[main]
|      +-[test]    <= Unit tests
+-[SERVICE] 
|  +-[src]
|      +-[main]
|      +-[test]    <= Unit tests
+-[TESTS] 
|  +-[src]
|      +-[main]
|      +-[test]    <= Integration tests

我可以通过“TESTS”文件夹中的集成测试来测量“CLIENT”和“SERVICE”模块的代码覆盖率吗?

4

2 回答 2

0

也许这篇文章可以帮助你: http ://www.lordofthejars.com/2012/07/jacoco-in-maven-multi-module-projects.html

我的建议:您可以运行所有测试并将它们记录在同一个 jacoco 执行数据文件中。但是当您为每个项目创建报告时,只会使用该项目的类。

于 2013-02-05T19:56:04.710 回答
0

The problem is that Jacoco needs the class files of the tested classes to create the report, which in your case are not available (because they are in different module). Here is a post which presents a solution to this by making the sources available with the maven-source-plugin. It uses ant, which is not an option in my case, but maybe it helps you:

http://olafsblog.sysbsb.de/measuring-test-coverage-of-integration-tests-for-separated-modules-with-jacoco/

于 2014-09-02T21:31:43.347 回答