TestCocoon

Open Source


Code Coverage Measurement for C/C++ and C#

  TestCocoon - Code Coverage Tool for C/C++ and C#

TestCocoon is a complete code coverage tool chain for C/C++ and C# programs available under Apple® Mac OS X, 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/C++ or C# applications:

  • Finding untested code sections.
  • Reducing the amount of tests by finding redundant tests.
    With TestCocoon 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:
    TestCocoon is able to calculate the optimal execution order of tests which maximize the overall coverage after each run.
  • Also, TestCocoon 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.

TestCocoon can be uses for every testing steps and methodologies (unit tests, automatic tests, manual white box tests, black box tests, etc…), and permits to collect and merge the execution reports together.

It is composed of 3 tools:

  1. CoverageScanner, which analyzes, instruments and generates the C/C++ or C# application.
  2. CoverageBrowser, which displays and manages the results of the coverage analysis. black box interactive tests.
  3. 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®.
/pictures/testcocoon_overview.png pictures/index_tmp.tmp001.png
Code Coverage Toolchain for C/C++ or C# Overview
Code Coverage Toolchain for C/C++ or C# Overview

  CoverageScanner - Instrumentation during the Generation

CoverageScanner instruments your source code during the compilation and generates an instrumented program, shared library or plugin. The instrumented program keeps track of the code instructions that were executed while the program was running (execution count or hit only are supported) and produces an execution report (csexe file) upon program termination. In order to get the best quality of code coverage metrics, CoverageScanner instruments not only on the function and statement level but also on the decision and condition level. Optionally, it is possible to insert in this report the test name and its execution status (passed or failed) using a batch script or directly in the application itself. This permits to integrate in a test framework (CppUnit, CxxTest, …) the generation of the code coverage information for each test item.



CoverageScanner is a command line tool which substitutes the compiler. Principally, it inserts instrumentation instructions into the preprocessed source code and calls up the native compiler. (GNU gcc or g++, Microsoft® Visuali Studio® 6.0, .NET, Express or Embedded C++ compiler, Intel® C++ compiler, …, or any other tool suite) A database (.csmes file), which contains the list of instrumentations and a copy of the instrumented source code, is generated at the same time. CoverageScanner is configurable via a profile and can be adapted to most compilers present on the market.



After the generation, the program can be run as usual and produces an execution report on exit. (.csexe file)

Info CoverageScanner has a special support Nokia Qt Library which permits to skip the instrument of code generated by the Meta-Object Compiler (MOC).

  CoverageBrowser - View, Analysis and Management of Code Coverage Result

The execution report can be analyzed and managed using CoverageBrowser.

It is a graphical interface which enables the user to browse and manage the execution reports. It therefore enables the user to find untested code portions, dead code and inefficient tests.

Overview of features:

  • Commenting instrumented source code lines.
  • Displaying list of executions in a tree view.
  • Managing a portion of code which can not be tested by setting it as "Manually Validated".
  • Browsing through instrumented code.
  • Switching between code coverage condition and code coverage branch analysis.
  • Displaying a detailed explanation of the state of the instrumentation. Including:
    • User comments.
    • The state (executed, not executed, partially executed).
    • The code coverage count.
    • The list of tests executing the instrumentation.
  • Retrieving the execution status from an automated test suite.
  • Code coverage analysis of unit tests.
  • Exporting statistics to to spreadsheets.
  • A test benefit analysis mode which permits to analyse the code coverage gain of a set of tests.
  • An API which permits to control CoverageBrowser using an external C/C++ application.
  • A source code and a method browser which displays code coverage statistics per files, classes, namespaces and C/C++ or C# functions.
  • Generation of a report in HTML format, which include statistics per source file, methods, executions and a list of unexecuted code parts. Click here to see an example.
  • CoverageBrowser supports black box testing.
  • New Feature: CoverageBrowser supports compararing coverage data of software releases.
/pictures/coveragebrowser_overview.png pictures/index_tmp.tmp002.png
CoverageBrowser: Code Coverage Screenshot
CoverageBrowser: Code Coverage Screenshot