客户端/服务器Web应用程序的代码覆盖率 [英] Code coverage of client/server web application

查看:253
本文介绍了客户端/服务器Web应用程序的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个多模块应用程序。一些模块只是基本的Java库,然后包含在webapp的WAR中。

I am writing a multi-module application. Some of the modules are just basic Java libraries which are then included in the WAR of a webapp.

我想在以下场景中运行代码覆盖:

I would like to run code coverage in the following scenario:


  • 我通过Maven启动的嵌入式Jetty运行webapp。

  • I am running the webapp through an embedded Jetty that is started via Maven.

我有针对webapp执行HTTP请求的测试。

I have tests which are executing HTTP requests against the webapp.

我想获得webapp中的代码以及测试。

I would like to get code covered in the webapp and also by the tests.

这是可能的,如何通过Cobertura,JaCoCo或Emma实现?据我所知,代码覆盖率仅涵盖此场景中的客户端代码。我是否正确?

Is this possible and how can it be achieved with Cobertura, JaCoCo or Emma? From what I understand, the code coverage will only cover the client-side code in this scenario. Am I correct?

推荐答案

我想如果你设法将JaCoCo-agent附加到运行码头的jvm,它应该能够测量在您针对您的webapp运行集成测试时调用了哪些代码。所以你应该得到一个显示代码覆盖率的统计数据。

I think if you would manage to attach the JaCoCo-agent to the jvm that runs the jetty, it should be able to measure which code has been called over the time you run the integration tests against your webapp. So you should get a statistic that shows you the code coverage.

有一个JaCoCo Maven插件 - 虽然我不确定这对你的情况是否有帮助。只是在单元测试中使用它。

There is a JaCoCo Maven Plugin - though I'm not sure if this will help with you scenario. Just used it during unit tests.

编辑:发现一个博客文章似乎指向正确的方向这里
通过与声纳的集成测试测量代码覆盖率

found a blog-post that seems to point in the right direction here Measure Code Coverage by Integration Tests with Sonar

这篇关于客户端/服务器Web应用程序的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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