Lesson 5 of 5
Fiori elements preview and testing RAP behavior
9 min
Listen to this lesson
With the binding published, Kenji opens the Fiori elements preview from the binding editor and sees a list report of agreements and an object page with items, driven entirely by the UI annotations in the projection's metadata extension. The preview is the developer's first end-to-end check. It is not a test strategy. SAP's RAP testing guide makes the case plainly: manual regression testing is slow and error-prone, so RAP apps need automated tests tailored to each artifact type, on more than one test level.
Unit tests for behavior
SAP's RAP guide describes unit tests for behavior implementations such as validations, determinations and actions, using the RAP BO test double framework to isolate the BO's dependencies. SAP's ABAP Unit cheat sheet names two variants: a transactional buffer test double (class CL_BOTD_TXBUFDBL_BO_TEST_ENV), which replaces the BO's buffer with one you fill with test instances, and a mock of the EML API (class CL_BOTD_MOCKEMLAPI_BO_TEST_ENV), which lets you configure what EML calls return. For a validation such as validateDates, a test inserts two agreements into the double, one valid and one with ValidTo before ValidFrom, calls the handler and asserts that only the second appears in failed and reported.
- class_setupCreate the RAP BO test environment for ZR_CMC_CoreAgreement
- setupClear the doubles; create the handler under test
- ArrangePut a valid and an invalid agreement into the transactional buffer double
- ActCall validateDates with both keys
- Assertfailed holds only the invalid key; reported has a message on ValidTo
- class_teardownDestroy the environment
Integration tests
Unit tests prove each rule alone. SAP's ABAP Cloud guide adds integration tests: with EML, a test creates an agreement with items, calls COMMIT ENTITIES and checks that determinations and validations worked together; with the OData client proxy, a test sends requests through the service so the projection, the projection BDEF and the binding are covered too. Integration tests touch the database, so they create their own data and clean up after themselves, and they run fewer cases than unit tests.
Two practical habits make these tests last. First, keep test data in the test: a handful of agreements for Great Lakes Fleet Services with known dates and deposits, created by the test itself, rather than records someone keyed into CMD months ago. Second, run the tests where the gate runs. When Kenji's team includes the BO's packages in the unit test and ATC runs attached to each transport, a later change to a determination that breaks TotalDeposit is caught in CMD, not in Mock 2 or, worse, by Dan at month-end.
| What to prove | Best level | Contoso example |
|---|---|---|
| A single rule | Unit test with RAP BO test double | validateDeposit rejects 0 for CMC-ALT-100 |
| Rules working together on save | EML integration test | Create, add two items, commit: TotalDeposit correct |
| What the service exposes | OData integration test | Delete is not offered; closeAgreement is |
| Usability and fit | Business acceptance in CMQ | Maria’s team maintains real agreements |
| Who may do what | Role-based tests in CMQ | Wave 2 users cannot change 1710 agreements |
Matching each question to the cheapest test level that answers it.
What would you do?
Priya proposes that Maria's team test every validation through the Fiori app in CMQ, because "that is how users will see it". Kenji suggests a different split. Which split is best?
- The Fiori elements preview is a developer check, not a test strategy.
- Unit-test handlers with the RAP BO test double framework (transactional buffer double or EML API mock).
- EML integration tests prove rules working together through COMMIT ENTITIES.
- OData integration tests cover the projection, projection BDEF and binding.
- Business acceptance proves fitness for use; it should not be the first place a rule is tested.
Check your understanding · not graded
Lesson check
1. Which class creates a transactional buffer test double for a RAP BO?
2. Which test type also covers the projection, projection BDEF and binding?
3. What is the Fiori elements preview best used for?
4. Which EML statement makes an integration test persist its changes?