Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 5 of 5

Coverage and gates

10 min

Listen to this lesson

0:00 / 14:50

Tests only protect a release if they run. On Contoso's program, Priya's exit criteria for the build phase ask for two things from development: evidence that custom code passed its automated checks, and an honest picture of what is not covered. This lesson covers how to measure coverage, what it does and does not tell you, and how ABAP Unit becomes part of the quality gates between CMD, CMQ and CMP.

Measuring coverage in ADT

In ADT, press Ctrl+Shift+F11, or right-click and choose Run As > ABAP Unit Test With..., select Coverage and execute. The ABAP Coverage view lists classes, methods and other processing blocks with their coverage; double-click to open the source, where executed lines are green, lines never executed are red, and branches that ran only one way are yellow. Hovering over a line shows how often it ran. If tests fail, ADT shows the ABAP Unit results first; fix the failures before reading coverage.

MetricCountsUse it to
Procedure coverageProcessing blocks (methods, function modules, form routines, event blocks) entered at least onceSpot whole methods nobody tests; SAP calls it a rough measure
Statement coverageStatements executedFind untested lines inside tested methods
Branch coverageWhether each condition (IF, CASE WHEN, LOOP, WHILE and others) was evaluated both true and falseFind untested paths, such as the error branch or the zero-quantity case

The three coverage measures in ABAP coverage analysis. Branch coverage is the most demanding.

If tests only use positive quantities, the condition is evaluated one way only: the branch shows yellow and the error path stays red.
The Sign-Off Table · thesignofftable.com/academy/sap-abp-205

What coverage does not prove

Coverage says which code ran during the tests. It says nothing about whether the tests checked the right results. A test with no assertion can produce 100% coverage. SAP's Clean ABAP guide is blunt: coverage helps you find code you forgot to test, it is not a KPI, and you should never write tests without real assertions just to raise it. Read coverage alongside the test names and assertions, and treat uncovered branches as a list of questions: is this path tested elsewhere, or is it a risk nobody has looked at?

Little evidenceFew tests, weak checks; treat the code as untested
False comfortLots of code runs, little is checked; the dangerous quadrant
Narrow but honestKey rules checked well; gaps are visible and can be risk-assessed
Strong evidenceMost paths run and outcomes are asserted; refactoring is safe
Coverage and assertion quality together. High coverage with weak assertions looks good on a dashboard and protects nothing.
The Sign-Off Table · thesignofftable.com/academy/sap-abp-205

Running unit tests in gates

ABAP Unit becomes a gate when tests run automatically at defined points and their result decides whether a change moves on. In an on-premise or private cloud landscape the building blocks are the ABAP Test Cockpit (ATC), whose check variants can include ABAP Unit tests alongside static checks; ATC checks on transport release, which can be configured to block release on findings of chosen priorities; scheduled ATC runs in the quality system; and the ABAP Unit Runner (report RS_AUCV_RUNNER), which runs the tests of selected packages in a background job and e-mails results.

The ABAP Unit Runner turns tests into a scheduled check in CMQ, with results e-mailed to the people who act on them.
The Sign-Off Table · thesignofftable.com/academy/sap-abp-205
  1. DeveloperKenji runs tests and ATC in ADT before releasing a task
  2. Transport release in CMDATC check variant with static checks and ABAP Unit; priority 1 and 2 findings block release under Contoso's settings
  3. Nightly in CMQScheduled Unit Runner job for the ZCMC packages; failures mailed to Kenji and Priya
  4. Release decisionResults linked to the feature in SAP Cloud ALM; open failures need a fix or a documented exemption
Where ABAP Unit runs on Contoso's path from CMD to CMP.
The Sign-Off Table · thesignofftable.com/academy/sap-abp-205
  • Make tests trustworthy first. A gate fed by flaky tests trains people to ignore red. Quarantine and fix flaky tests quickly.
  • Keep gate tests HARMLESS and SHORT. Client settings can block riskier tests, and slow tests make developers skip the gate.
  • Gate on failures, not on a coverage number. Use coverage trends for review conversations instead.
  • Make exemptions visible. Every skipped or exempted test needs an owner and an end date.

What would you do?

Grace proposes a rule for the program: "No transport leaves CMD unless its classes have at least 80% statement coverage." Kenji is asked for his view. What is the best response?

Key points
  • Measure coverage with Ctrl+Shift+F11 and read it in the ABAP Coverage view.
  • Procedure, statement and branch coverage show what ran, never whether results were checked.
  • ATC check variants, transport release checks and the ABAP Unit Runner turn tests into gates.
  • Gate on failures; use coverage for review; keep gate tests HARMLESS, SHORT and reliable.

Check your understanding · not graded

Lesson check

  1. 1. Which coverage measure shows whether an IF condition was evaluated both true and false?

  2. 2. A class has 100% statement coverage. What does that prove?

  3. 3. What does the ABAP Unit Runner report RS_AUCV_RUNNER do?

  4. 4. Why should tests used in a gate be reliable before the gate is switched on?