Code Coverage Analysis

Code coverage is a metric used to gauge the completeness of software testing, by identifying which areas of source code in an application were exercised during a test. It provides a convenient way to ensure that applications are not released with untested code. The basic forms of code coverage can be defined as:

  • Function coverage – Has each function (or subroutine) in the program been called?
  • Statement coverage – Has each statement in the program been executed?
  • Branch coverage – Has each branch of each control structure been executed?
  • Condition coverage – Has each Boolean sub-expression evaluated both to true and false?

For more complex, safety critical, systems a more complex metric based on function coverage and branch coverage known as Modified Condition/Decision Coverage (MC/DC) is used which stipulates that each entry and exit point is invoked, each decision takes every possible outcome, each condition in a decision takes every possible outcome and each condition in a decision is shown to independently affect the outcome of the decision.

Code Coverage using Squish Coco

Squish Coco code coverage colorsSquish Coco is a multi-language code coverage tool supporting C/C++, C# and Tcl.  Squish Coco utilises source code instrumentation to analyze the applications’ source code with no manual changes to source code being necessary.

When the test suite is executed, the instrumented application produces data that can later be analyzed.

This analysis can be used to determine how much of the source code has been exercised by the tests, which additional tests need to be written, how the test coverage changed over time and more.

While other code coverage tools typically just accumulate coverage data Squish Coco stores information per individual test. With an optional name and FAIL vs. PASS status assigned. This way various types of analysis can be performed in the post-processing phase:

  • Calculation of the optimal order of test execution to quickly maximize the overall coverage
  • Comparison of coverage between test executions
  • Comparison of coverage between different software builds
  • Analysis of test coverage for source code patches in the review process
  • Determines minimal set of tests to cover a source code patch

Code coverage is not a final activity, but rather a continual activity toward a reliable system. The earlier it is employed the better. It provides scope to add tests, improve tests, remove redundant tests, and cover more code, ensuring higher quality and more reliable systems. More details…

Find out more…

For more information on how code coverage analysis with Squish Coco from froglogic please complete the form below.

Full Name (required):

Company Name (required):

Your Email (required)