Guide · Code coverage

Code coverage and standards: what each one requires

Aerospace, automotive, industry, rail, medical, agricultural machinery, nuclear: each functional safety standard sets its own coverage requirements. Here, standard by standard, are the levels required according to the criticality of the software, and what they have in common.

Principle

What they have in common

The figures differ, but the logic is the same everywhere.

The level follows criticality

The more serious a failure would be, the more demanding the required coverage: statements for the least critical software, up to MC/DC for the most critical.

Measured on requirements-based tests

Coverage is used to assess the tests written from the requirements. It shows what they did not execute; it does not replace those tests.

Every gap is explained

Whatever remains uncovered is dealt with: one more test, a completed requirement, deleted code, or a written justification handed to the audit.

"Highly recommended"

In ISO 26262, IEC 61508 or EN 50716, a highly recommended method that is not applied must be justified. In practice, it is expected.

For the levels themselves (statement, decision, condition, MC/DC), see coverage levels.

Summary

The summary table

For each standard, its criticality levels and what the most demanding one requires.

StandardLevelsAt the most critical level
DO-178CAerospaceA to EMC/DC, decision and statement coverage, at level A
ISO 26262AutomotiveASIL A to DMC/DC and branch coverage highly recommended, at ASIL D
IEC 61508IndustrySIL 1 to 4MC/DC, branch, statement and entry point coverage highly recommended, at SIL 4
EN 50716RailBasic integrity, SIL 1 to 4Branch and compound condition, or branch and data flow, or path coverage, at SIL 3 and 4
IEC 62304MedicalClasses A, B, CNo level imposed: the manufacturer sets its criteria
ISO 25119Agricultural machinerySRL B, 1, 2, 3Entry point, statement and branch coverage, at SRL 2 and 3
IEC 60880NuclearCategory AAll lines of code, and all module calls at integration (common position of the safety authorities)
Aerospace

DO-178C

Airborne software is classified from level A, catastrophic failure, to level E, no effect. Structural coverage is required at 100% from level C upwards.

LevelStructural coverage required
AMC/DC, decision and statement coverage; data coupling and control coupling; verification of object code that is not directly traceable to the source code
BDecision and statement coverage; data coupling and control coupling
CStatement coverage; data coupling and control coupling
D and ENo structural coverage

Data coupling and control coupling analysis checks that the tests exercise the data exchanges and call dependencies between the software components. Tool qualification is covered by a separate document, DO-330. The DO-178C page

Automotive

ISO 26262

Part 6 of ISO 26262 (2018 edition) recommends coverage according to the ASIL, from A, the least demanding, to D, at two test levels.

CoverageASIL AASIL BASIL CASIL D
Software unit testing
Statement++++++
Branch+++++++
MC/DC+++++
Integration testing (software architecture)
Function++++++
Call++++++

++: highly recommended. +: recommended.

At ASIL C and D, statement coverage is only recommended: it is included in branch coverage, which is highly recommended. The standard sets no percentage: coverage judged insufficient calls for additional tests or a justification. The ISO 26262 page

Industry

IEC 61508

The basic functional safety standard, from which several sector standards derive. Part 3 (2010 edition) recommends 100% coverage according to the safety integrity level, from SIL 1 to SIL 4.

100% coverageSIL 1SIL 2SIL 3SIL 4
Entry points++++++++
Statements+++++++
Branches++++++
MC/DC+++++

++: highly recommended. +: recommended.

When 100% cannot be achieved, for instance because of defensive code, the reason must be explained. The IEC 61508 page

Rail

EN 50716

Published in 2023, EN 50716 replaces EN 50128 and EN 50657 for railway software. In addition to statement and branch coverage, it lists compound conditions, data flow and paths.

CoverageSIL 1SIL 2SIL 3SIL 4
Statement++++++++
Branch++++++
Compound conditions++++++
Data flow++++++
Path++++++

++: highly recommended. +: recommended.

At SIL 3 and 4, the standard requires a combination at component level: branch and compound conditions, or branch and data flow, or path; or, at integration level, one or more of these criteria. Other criteria may be used if they are justified. The EN 50716 page

Medical

IEC 62304

IEC 62304 classifies medical device software into three classes, from A, no injury possible, to C, death or serious injury possible. It imposes no coverage level: the manufacturer sets its own acceptance criteria for its software units, with additional criteria for class C, and must be able to defend them.

For the US market, the FDA guidance on software validation (General Principles of Software Validation) considers decision coverage a minimum level for most software products, and insufficient on its own for high-integrity applications.

Aiming at least for decision coverage, as the FDA suggests, and more for class C, gives a criterion that is easy to defend. The IEC 62304 page

Agricultural machinery

ISO 25119

ISO 25119 applies to tractors and machinery for agriculture and forestry. Its software requirement level, the SRL, ranges from B to 3. For software component testing, part 3 requires, at SRL 2 and SRL 3, proof of structural coverage of the source code: entry points, statements and branches.

It does not explicitly require 100%: the target is to be set and justified in the project. The ISO 25119 page

Nuclear

IEC 60880

IEC 60880 governs the software of category A systems in nuclear power plants, those that perform the most important safety functions. The expectations of the European nuclear safety authorities are set out in their common position on the licensing of safety critical software (Licensing of safety critical software for nuclear reactors).

In its 2013 edition, this document requires the tests to exercise all lines of code and, at system integration, all module calls, with a coverage analysis to justify it. It also requires testing the boundaries of every input variable, the error handling mechanisms and access to all data items. The IEC 60880 page

Tools

The measurement tool must be qualified too

A coverage tool that got it wrong would make the tests look complete. The standards therefore require making sure it can be trusted.

Assess the tool

ISO 26262, IEC 61508, EN 50716 and DO-178C, with DO-330, require each tool to be assessed according to the risk it introduces, then qualified if necessary.

A certificate lightens the work

A certificate issued by a body such as TÜV SÜD, with its safety package, saves you from repeating the demonstration yourself.

Use it as intended

The certificate applies to a use described in the tool's safety manual: that is the framework to follow on the project.

Testwell CTC++

All these requirements with Testwell CTC++

Testwell CTC++ measures every level required by these standards on C and C++ code (Java as an option), from function coverage to MC/DC and multiple condition coverage:

  • on the host as well as on the embedded target, whatever the compiler;
  • with the justifications of uncovered parts in the reports;
  • certified by TÜV SÜD for IEC 61508, ISO 26262, EN 50716, ISO 25119 and IEC 62304, with a safety package that lightens tool qualification.

Certification →
Testwell CTC++ →

Lighter tool qualification1 min 22 s · silent animation
TiCS

Tracking coverage with TiCS

TiCS takes in the coverage measured by Testwell CTC++ or by another coverage tool:

  • coverage is shown per test level, and in total;
  • it feeds into the TQI, alongside the other code quality indicators;
  • its evolution can be followed from one version to the next, which prepares reviews and audits.

TiCS →
Guide: static code analysis →

Coverage, level by level1 min 36 s · silent animation

Key points

  • Every standard links the coverage level to the criticality of the software.
  • MC/DC is required or highly recommended at the highest level of DO-178C, ISO 26262 and IEC 61508.
  • EN 50716 combines branch, compound condition, data flow and path coverage at SIL 3 and 4.
  • IEC 62304 and ISO 25119 leave it to the manufacturer to set and justify its target.
  • Whatever remains uncovered is always explained, and the measurement tool is qualified too.
FAQ

Frequently asked questions

Is "highly recommended" mandatory?

Not strictly, but a highly recommended method that is not applied must be justified, and the assessor will examine that justification. In practice, it is applied.

Do you need to reach 100%?

DO-178C and IEC 61508 aim for 100%, explaining what cannot be covered. ISO 26262, IEC 62304 and ISO 25119 set no percentage: the target is defined and justified on the project.

On which tests is coverage measured?

On requirements-based tests: unit tests for statement, branch and MC/DC coverage, integration tests for function and call coverage. Tests written only to push the figure up prove nothing.

Does my coverage tool need to be certified?

No, but it must be assessed, and qualified if its risk level requires it. A certificate such as that of Testwell CTC++ lightens this work for the standards it covers.

Source code or object code?

Coverage is measured on the source code. At level A, DO-178C also requires verifying the code that the compiler adds with no direct link to the source.

What about cybersecurity standards?

IEC 62443 and ISO/SAE 21434 deal with cybersecurity and are not covered in this guide; see the IEC 62443 and ISO/SAE 21434 pages.

Reach the coverage your standard requires

A free trial of Testwell CTC++ on your own C or C++ code, on the host or on the embedded target.

Free trial →

Code coverage  ·  Coverage levels  ·  MC/DC  ·  Certification  ·  Standards  ·  Learn

Sources: RTCA DO-178C / EUROCAE ED-12C (2011); ISO 26262-6:2018; IEC 61508-3:2010; EN 50716:2023; IEC 62304:2006+A1:2015; ISO 25119-3:2018; FDA, General Principles of Software Validation (2002) ↗; European nuclear safety authorities, Licensing of safety critical software for nuclear reactors (2013) ↗. The standards define their requirements in detail: refer to their text for your project.