Code coverage is a measure used in software testing that describes the degree to which the source code of a program has been tested. It a form of white box testing as it is a form of testing that inspects the code directly.

Recommended Reading:

To measure how well the software is tested by a test suite, one or more coverage criteria are used. There are a number of coverage criteria and here are the important ones:

Function coverage – that says if each function in the program been executed or not Statement coverage – that says if each line of the source code been executed or not Decision coverage (also known as Branch coverage) – that says if each control structure such as an if statement has been evaluated both to true and false Condition coverage – says if each boolean sub-expression has been evaluated for both true and false Path coverage – that says if every possible route through a given part of the code been executed or not Entry/exit coverage – that says if every possible call and return of the function been executed or not

In this article, we cover the popular Code Coverage tools to measure Code Coverage.

1. Testwell CTC++

CTC++ is a powerful instrumentation-based test coverage and dynamic analysis tool for C and C++ code. As a coverage tool, CTC++ shows the coverage all the way to the Modified Condition/Decision Coverage (MC/DC) level. As a dynamic analysis tool, CTC++  shows the execution counters in the code, i.e. more than plain boolean coverage information. You can also use CTC++ to measure function execution costs (normally time) and to enable function entry/exit tracing at test time

2. CoverageMeter

CoverageMeter is a complete code coverage tool chain for C/C++ programs available under Linux or Microsoft Windows. It analyzes the performance of a software validation and permits to measure the performance and optimizes the testing process of a C or C++ applications by:

  • Finding untested code sections.
  • Reducing the amount of tests by finding redundant tests – With CoverageMeter it is possible to find which portion of the source code is covered only by one execution of a test, and to detect if a new test does not cover more source code line than existing tests.
  • Finding dead code trough displaying the code parts which are never executed.
  • Specially useful for manual testing – CoverageMeter is able to calculate the optimal execution order of tests which maximize the overall coverage after each run.
  • Also, CoverageMeter is able to perform its analysis on a difference of two applications.
  • This permits to find which tests are impacted by a source code modification and permits to measure the test quality of a patch or a hot fix.

It is composed of 4 tools:

With CoverageScanner you can analyzes, instrument and generate the C/C++ application. CoverageBrowser displays and manages the results of the coverage analysis. Execution Agent is a small free tool which is dedicated to manual tests and specially for black box interactive tests. It also has an optional Microsoft Visual Studio 2005 & 2008 Add-In which permits to generate code coverage configurations from every C/C++ projects created by Microsoft® Visual Studio.

3. BullseyeCoverage

BullseyeCoverage is a code coverage analyzer for C++ and C that tells you how much of your source code was tested. You can use this information to quickly focus your testing effort and pinpoint areas that need to be reviewed. Here are some of the features of BullseyeCoverage:

  • Function coverage gives you a quick overview and condition/decision coverage gives you high precision
  • Works with everything you can write in C++ and C, including system-level and kernel mode
  • Short learning curve
  • Integrated with Microsoft Visual Studio
  • Include or exclude any portion of your project code
  • Run-time source code included, for custom environments

4. GCT

GCT is a C Code Coverage Tool. GCT was the third coverage tool by Brian Marick. It instruments C code in a source-to-source translation, then passes the instrumented code to a compiler. It is suitable for measuring the coverage of embedded systems as it was first used on a Unix kernel. In addition to branch and multiple-condition coverage, it also has boundary-condition and loop coverage. For more details on this tool check the tutorial at testingcraft.com

5. CppUnit

CppUnit is a unit testing framework module for C++, described as a C++ port of JUnit. The library is released under the GNU Lesser General Public License

6. Dynamic Code Coverage

Dynamic Code Coverage identifies untested portions of your software code, so your team can focus attention on those undiscovered areas, and improve your software quality immediately. Dynamic Code Coverage builds a detailed coverage analysis, covering every function, line, decision, and branch. Coverage files from subsequent multiple runs get added in. You can look at the information you gather in a variety of ways. And you can annotate each source file with function, line, decision, and branch information.

7. TCAT C/C++

TCAT C/C++ for Windows measures the Effectiveness of Tests, Test Suites. It identifies untested code and improves test efficiency.

It provides a combined branch and call-pair coverage for C-C++. It provides annotatable calltree displays and digraph displays with access to source.

8. COVTOOL

COVTOOL is an open source test coverage analyzer for C++ programs. It lets you dynamically instrument your source code as you compile. An instrumented program keeps track of the lines of code that were executed during its run and produces a log of the same upon program termination. Multiple program runs will produce multiple logs. You can then use the many log files generated during a suite of tests to analyze test coverage percentages. Most importantly, you can use the coverage information to annotate your source. Thus you can find which lines in which source files did not get executed during your entire suite of tests. Code that has been tested may still be buggy, but you should have almost no confidence in code that is never tested.

9. gocv

gcovis a tool you can use in conjunction with GCC to test code coverage in your programs. You can use it with along with GCC to analyze your programs to help create more efficient, faster running code and to discover untested parts of your program. You can use gcov tool to help to understand where your optimization efforts will best affect your code. You can also use gcov along with the other profiling tool, gprof, to assess which parts of your code use the greatest amount of computing time.

10. xCover

xCover is a Code Coverage library for C and C++, written in C. xCover itself is a platform-independent library. It has been tested and used on both UNIX and Windows – in principle, it should work on any operating system for which a compatible C/C++ compiler exists.

10 Code Coverage Tools for C & C++的更多相关文章

  1. iOS 9 学习系列: Xcode Code Coverage

    Code coverage 是一个计算你的单元測试覆盖率的工具. 高水平的覆盖给你的单元測试带来信心.也表明你的应用被彻底的測试过了. 你可能写了几千个单元測试,但假设覆盖率不高.那么你写的这套測试可 ...

  2. 使用Visual Studio Code Coverage和nunit上传单元测试覆盖率和单元测试结果到SonarQube上

    SonarQube.Scanner.MSBuild.exe begin /k:"OMDCCQuotes" /d:sonar.host.url="http://myip:9 ...

  3. Top 40 Static Code Analysis Tools

    https://www.softwaretestinghelp.com/tools/top-40-static-code-analysis-tools/ In this article, I have ...

  4. Gumshoe - Microsoft Code Coverage Test Toolset

    Gumshoe - Microsoft Code Coverage Test Toolset 2014-07-17 What is Gumshoe? How to instrument a binar ...

  5. CI集成phpunit Error: No code coverage driver is available 的解决

    CI集成phpunit时,运行报No code coverage driver is available的错误,如下图: yanglingdeMacBook-Pro:tests yangling$ p ...

  6. 测试工具 - IDEA - IDEA Code Coverage

    概述 使用 idea 自带的 code coverage 工具 背景 了解 白盒测试用例设计 和 测试覆盖率 之后, 大概就需要 实践 了 实践的话, 还是需要 工具 来检验效果 工具选取 选项 Ja ...

  7. [Jest] Track project code coverage with Jest

    Jest comes pre-packaged with the ability to track code coverage for the modules you're testing, but ...

  8. Effective Java提升Code Coverage代码涵盖率 - 就是爱Java

    虽然我们已经有了测试程序,但是如何得知是否已完整测试了主程序?,透过Code Coverage代码涵盖率,我们可以快速地得知,目前系统中,有多少程序中被测试过,不考虑成本跟投资效益比,涵盖率越高,代表 ...

  9. .NET CORE 框架ABP的代码生成器(ABP Code Power Tools )使用说明文档

    前言 各位好,又是一个多月没更新文章了. 原因嘛,大家都懂的,太忙了~ 临近年末,公司的项目.年会的做技术支持,同事朋友聚餐也比较频繁. 当然视频教程也没有继续更新.我的锅~ 但是这个月好歹抽空做了一 ...

随机推荐

  1. 手动编译Jsp文件

    手动模拟Tomcat编译jsp文件 Tomcat编译jsp文件的配置路径是在%tomcat_home%/conf/web.xml中,有这样一段代码 <servlet> <servle ...

  2. HDFS的运行原理(转)

    简介 HDFS(Hadoop Distributed File System )Hadoop分布式文件系统.是根据google发表的论文翻版的.论文为GFS(Google File System)Go ...

  3. SyntaxError: Non-UTF-8 code starting with '\xba' in file 错误的解决方法!!

    第一次在Eclipse建立python工程,添加了自己新建的文件,写了一点代码,随后执行时候出现了错误,和昨天我在Visual Studio 2015里面一样,错误: SyntaxError: Non ...

  4. Win8驱动测试模式

    打开驱动测试模式(保存成bat文件,双击执行) bcdedit /set testsigning on pause 执行完成后,看见提示操作成功的提示,之后我们重启一下,再次进入系统,在桌面的右下角会 ...

  5. MYSQL C API : mysql_init()

    MYSQL * mysql_init(MYSQL *mysql); // 初始化一个MYSQL 连接的实例对象 void mysql_close(MYSQL *sock); // 释放一个MYSQL ...

  6. cshell学习

    一. 文件的读写执行: 1)读:可以显示该文件的内容 2)写:可以编辑或者删除它 3)执行:如果该文件是一个shell脚本或者程序. 如果希望一次设置目录下所有文件的权限,可使用:chmod 644 ...

  7. crm 4 注释与上传附件权限

    文档注释权限及上传附件是与实体的”追加到”权限有关. 文档注释权限及上传附件是与核心记录中”注释”的”追加”权限有关. 追加及追加到的权限,我的理解是与本实体有关联的实体的权限,比如你引用了其它表的字 ...

  8. springMVC spring hibernate pom.xml备份

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  9. 菜鸟-教你把Acegi应用到实际项目(9)-实现FilterInvocationDefinition

    在实际应用中,开发者有时需要将Web资源授权信息(角色与授权资源之间的定义)存放在RDBMS中,以便更好的管理.事实上,我觉得一般的企业应用都应当如此,因为这样可以使角色和Web资源的管理更灵活,更自 ...

  10. MySQL的循环语句使用总结

    REPEAT-UNTIL循环 [loopname]:REPEAT commands; UNTIL condition END REPEAT [loopname]; 在这种循环里,关键字repeat和u ...