Lesson 6 of 6
A RAP test standard for code review and quality gates
11 min
Listen to this lesson
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
| Rule | What reviewers look for |
|---|---|
| 1. Test map first | Every BDEF element (validation, determination, action, feature, authorization, draft) has a test row |
| 2. Test relation | Each test class names its BDEF with "! @testing BDEF:... |
| 3. HARMLESS and SHORT | All BO tests run in the gate client; anything slower needs a reason |
| 4. Doubles, not data | CDS, SQL or buffer doubles; no reads of records keyed by hand |
| 5. Commit in scenarios | At least one committing scenario per main path; negative tests per validation |
| 6. Draft tests | Draft create, Prepare, failed Activate keeps the draft, successful Activate |
| 7. Restricted users | Authorization tests use the authority check helper |
| 8. No local mode in proofs | Rules are proven through consumer calls |
| 9. Messages asserted properly | Class, number, element; every failed key has a message |
| 10. Clean up | ROLLBACK ENTITIES in teardown; destroy environments in class_teardown |
Contoso's RAP test standard. The code review checklist uses the same numbers.
The gate, step by step
- 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.
- 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.
- 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. - 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.
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, nottest_3. - Assertions per test. A test with no
cl_abap_unit_assertcall 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 MODEin a test that proves feature control or authorization.
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?
- 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. What should Contoso gate a RAP transport on?
2. Which report runs ABAP Unit tests of selected packages in a background job?
3. Why is a coverage target a poor gate?
4. What must every quarantined test have in Contoso's gate?
5. Which name best fits Contoso's standard for a test method?