功能测试的代码覆盖率 [英] Code coverage for functional tests

查看:575
本文介绍了功能测试的代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java RESTful API。我在每个端点上使用 REST Assured 进行功能测试。

有没有办法当REST Assured(或任何类似的工具)调用API时,获取场景背后使用的类/方法(控制器,服务,DAO /存储库等)的代码覆盖率? (我想API应该从一些代理开始,或者报告在停止之前会发生什么?)。

I have a Java RESTful API. I use REST Assured for my functional tests on each endpoint.
Is there a way to get the code coverage for the classes/methods used behind the scene (controllers, services, DAOs/repositories, etc.) when REST Assured (or any similar tool) makes calls to the API? (I guess the API should be started with some agent or something that reports what happens until it is stopped?).

推荐答案

你也可以使用像 Sealights 这样的服务,因为这是我们解决的问题(我在那里工作) - 获取代码覆盖率超出单元测试,这意味着您的所有功能,Selenium,集成,性能测试都会报告到一个仪表板中。

You can also use a service like Sealights as this is the problem we solve (I work there) - get code coverage beyond unit tests, meaning that all of your Functional, Selenium, Integration, Performance testing are reported into a single dashboard.

请注意,您使用的解决方案(JaCoCo)是好的,但它有一些缺点,例如:

Note that the solution you have used (JaCoCo) is OK but it has drawbacks such as:


  • 仅适用于Java。

  • 您必须从多台计算机上收集保险并将其统一(假设您有微服务或许多服务器)才能获得最终报告。

  • 只有当过程失败时才能使用保险范围,因此如果您进行了很长时间的测试,可能需要几个小时才能获得初始信息。

  • Is it only for Java.
  • You have to collect the coverage from multiple machines and unify it (assuming that you have micro-services or many servers) in order to get the final report.
  • The coverage is available only when the process is going down so if you have very long tests, it may take you hours till you'll have your initial info.

您无法看到后端和后端的覆盖范围。前端代码在一个位置。

You can't see the coverage of your backend & frontend code in a single location.

基本上在Sealights中我们解决所有这些问题,帮助您集中测试在代码中已更改的区域中,提供状态报告将向您显示您的团队的工作方式,包括如何优化测试以及其他一些很酷的功能的提示。

Basically in Sealights we solve all of those problems, help you to focus your tests in areas in the code which have changed, provide status reports will show you how your team is doing including tips on how to optimize your tests and some other cool features.

最后但同样重要的是,目前我们支持Java,NodeJS,基于浏览器的测试(即Selenium),.NET和Python。

Last but not least, currently we support Java, NodeJS, Browser Based Tests (ie, Selenium), .NET and Python.

快乐编程; - )

这篇关于功能测试的代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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