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.
Image Source : http://www.zeeteenet.com/images/sw_testing.jpg
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.
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
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:
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.
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:
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
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
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.
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.
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.
gcov is 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.
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.