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

Lesson 6 of 6

A RAP test standard for code review and quality gates

11 min

Listen to this lesson

0:00 / 9:30

Good tests written by one developer are luck. A test standard makes them normal. Before Contoso's next RAP BO, the fleet warranty claim object, Kenji and Priya wrote a one-page RAP test standard, built the ATC and ABAP Unit gate around it, and agreed what evidence goes into SAP Cloud ALM. This lesson turns the course into that standard.

The standard, in ten rules

RuleWhat reviewers look for
1. Test map firstEvery BDEF element (validation, determination, action, feature, authorization, draft) has a test row
2. Test relationEach test class names its BDEF with "! @testing BDEF:...
3. HARMLESS and SHORTAll BO tests run in the gate client; anything slower needs a reason
4. Doubles, not dataCDS, SQL or buffer doubles; no reads of records keyed by hand
5. Commit in scenariosAt least one committing scenario per main path; negative tests per validation
6. Draft testsDraft create, Prepare, failed Activate keeps the draft, successful Activate
7. Restricted usersAuthorization tests use the authority check helper
8. No local mode in proofsRules are proven through consumer calls
9. Messages asserted properlyClass, number, element; every failed key has a message
10. Clean upROLLBACK ENTITIES in teardown; destroy environments in class_teardown

Contoso's RAP test standard. The code review checklist uses the same numbers.

The four points where Contoso's RAP tests run, from the developer's editor to the release decision.
The Sign-Off Table · thesignofftable.com/academy/sap-abp-304

The gate, step by step

  1. In ADT. Before releasing a task, Kenji runs ABAP Unit on the behavior definition (Ctrl+Shift+F10), which also runs the related test classes, then runs it with coverage (Ctrl+Shift+F11) and reads branch coverage of the behavior pool.
  2. On transport release. The ATC check variant used at release includes ABAP Unit; under Contoso's settings, priority 1 and 2 findings block release, as set up in the ATC course.
  3. Nightly in CMQ. The ABAP Unit Runner (report RS_AUCV_RUNNER) runs the tests of the ZCMC packages in a background job and mails failures to Kenji and Priya.
  4. At the release decision. Results are linked to the feature in SAP Cloud ALM; open failures need a fix or a documented exemption with an owner and end date.

Coverage: a question list, not a target

Branch coverage of the behavior pool shows paths no test has taken. For the agreement BO, the first coverage run showed the CLOSED branch of the close action and the empty-items branch of calcTotalDeposit in red. Each red branch became a question for the review: is it tested elsewhere, is it a risk, or is it dead code? Contoso does not gate on a coverage percentage; it gates on failures and reviews coverage trends. A test without assertions can reach 100% and prove nothing.

UntestedFew tests, weak checks: treat the BO as untested
False comfortCode runs, little is asserted: the dangerous quadrant
Narrow but honestKey rules asserted well; gaps known and risk-assessed
Strong evidenceMost branches run and outcomes are asserted
How Priya reads a behavior pool's test evidence.
The Sign-Off Table · thesignofftable.com/academy/sap-abp-304

Introducing the standard to existing code

The agreement BO was written before the standard. Kenji did not stop feature work to retrofit everything; he applied a simple rule: any behavior pool touched in a sprint leaves that sprint compliant for the handlers that changed, plus a scenario test for its main path. The test map shows the remaining gaps as a backlog that Priya reviews every two-week sprint. Within three sprints, every handler of the agreement BO had a test, and the gaps left were the CMQ-only checks. For the warranty claim BO, the standard applied from the first commit.

Code review: what to read first

  • Test names. They should read like requirements: closed_agreement_cannot_be_updated, not test_3.
  • Assertions per test. A test with no cl_abap_unit_assert call is not a test.
  • Dependency lists. Every table and view the BO touches is doubled.
  • Phase. For each validation, the test commits or runs Prepare.
  • Mode. No IN LOCAL MODE in a test that proves feature control or authorization.
The lifecycle of a failing RAP test in Contoso's gate. Nothing stays red or quarantined without an owner.
The Sign-Off Table · thesignofftable.com/academy/sap-abp-304

What goes wrong in testing

  • Gate fed by flaky tests. Tests that depend on client data turn red after a refresh, and people learn to ignore red.
  • Coverage targets. A mandated percentage produces tests without assertions.
  • Silent exemptions. An exempted test without an end date is a permanent hole.
  • Standard without examples. Kenji's team keeps the agreement BO's test classes as the reference implementation linked from the standard.

What would you do?

Grace's steering group wants a single quality number for RAP apps and proposes "90% statement coverage before transport to CMP". What should Priya recommend instead?

Key points
  • Write a short RAP test standard and use its rules as the code review checklist.
  • Run tests in ADT, on transport release through ATC, nightly in CMQ, and link results in SAP Cloud ALM.
  • Gate on failures and findings; read coverage as a list of questions.
  • Every quarantined or exempted test has an owner and an end date.

Check your understanding · not graded

Lesson check

  1. 1. What should Contoso gate a RAP transport on?

  2. 2. Which report runs ABAP Unit tests of selected packages in a background job?

  3. 3. Why is a coverage target a poor gate?

  4. 4. What must every quarantined test have in Contoso's gate?

  5. 5. Which name best fits Contoso's standard for a test method?