如何测量CppUnit测试覆盖率(在Win32和Unix上)? [英] How can I measure CppUnit test coverage (on win32 and Unix)?

查看:194
本文介绍了如何测量CppUnit测试覆盖率(在Win32和Unix上)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常大的代码库,其中包含大量的单元测试(使用CppUnit)。 我需要确定这些测试将执行多少代码,并(理想情况下)生成某种报告,以每个库或每个文件为基础,告诉我多少代码已被执行。

I have a very large code base that contains extensive unit tests (using CppUnit). I need to work out what percentage of the code is exercised by these tests, and (ideally) generate some sort of report that tells me on a per-library or per-file basis, how much of the code was exercised.

这里是关键:必须完全无人值守运行(最终在连续集成构建中),并且必须跨平台运行(嗯,WIN32和*至少nix)。

Here's the kicker: this has to run completely unnatended (eventually inside a continuous integration build), and has to be cross platform (well, WIN32 and *nix at least).

任何人都可以建议一个工具或一组工具来帮助我吗?我不能离开CppUnit(我也不想-它会踢屁股),但是否则,我很想听听您可能有任何建议。

Can anyone suggest a tool, or set of tools that can help me do this? I can't change away from CppUnit (nor would I want to - it kicks ass), but otherwise I'm eager to hear any recommendations you might have.

干杯,

推荐答案

我应该使用哪个工具?


文章介绍了另一位寻求C ++代码覆盖率工具的开发人员感到沮丧。作者的最终解决方案是 Bullseye Coverage

Which tool should I use?

This article describes another developers frustrations searching for C++ code coverage tools. The author's final solution was Bullseye Coverage.

靶心覆盖范围功能:

Bullseye Coverage features:


  • 跨平台支持(win32,unix和嵌入式),(支持linux gcc编译器和MSVC6)

  • 易于使用(几个小时即可启动并运行)。

  • 提供最佳指标:功能覆盖率和条件/决策覆盖率。

  • 使用源代码工具。

  • Cross Platform Support (win32, unix, and embedded), (supports linux gcc compilers and MSVC6)
  • Easy to use (up and running in a few hours).
  • Provides "best" metrics: Function Coverage and Condition/Decision Coverage.
  • Uses source code instrumentation.

As挂钩到持续集成的过程取决于您使用哪种CI解决方案,但是您可能会将仪表/覆盖率测量步骤挂钩到用于自动测试的make文件中。

As for hooking into your continuous integration, it depends on which CI solution you use, but you can likely hook the instrumentation / coverage measurement steps into the make file you use for automated testing.

只要您的所有测试都能在两种环境中正常运行,您就可以很好地衡量一个或另一个的覆盖率。 (尽管Bullseye出现支持这两个平台)。但是为什么不在两种环境中都进行持续集成呢?如果您同时在两种环境中交付给客户,则需要在这两种环境中进行测试。

So long as all your tests run correctly in both environments, you should be fine measuring coverage on one or the other. (Though Bullseye appears to support both platforms). But why aren't you doing continuous integration builds in both environments?? If you deliver to clients in both environments then you need to be testing in both.

因此,听起来您可能需要连续进行两次构建服务器设置,一个用于linux构建,一个用于Windows构建。也许可以使用某些虚拟化软件轻松实现此目的,例如 vmware virtualbox 。您可能不需要在两个操作系统上都运行代码覆盖率指标,但是绝对应该在两个操作系统上都运行单元测试。

For that reason, it sounds like you might need to have two continuous build servers set up, one for a linux build and one for a windows build. Perhaps this can be easily accomplished with some virtualization software like vmware or virtualbox. You may not need to run code coverage metrics on both OSs, but you should definitely be running your unit tests on both.

这篇关于如何测量CppUnit测试覆盖率(在Win32和Unix上)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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