EML Part 5: Testing RAP with EML and Transactional Consistency
Preview · a free account unlocks the full lesson
Use EML to prove that a RAP business object behaves correctly and consistently: test structure, isolating tests, checking permissions and messages, testing draft and bulk behavior, and simulation for pre-checks.
In this lessonShow sectionsHide sections
Visual overview
Explanation
By now EML can be used fluently, as covered across Parts 1 through 4. The last step is using it to verify behavior automatically. Behavior Implementations Part 5 introduced unit tests; this lesson goes further into what to test and how to keep those tests reliable.
EML is the right test interface because OData, Fiori and other BOs all ultimately end up in the same RAP runtime that EML itself uses. A test that creates, changes and commits via EML exercises the real behavior — authorization, feature control, determinations, validations, draft — without needing a UI at all, and such tests stay fast, repeatable, and suitable for CI.
A good test follows a consistent structure. Arrange by preparing input with %cid and setting up test doubles for any data the BO reads, such as supplier master data. Act with one EML operation, or a short sequence of them — MODIFY, EXECUTE, COMMIT ENTITIES RESPONSE. Assert against FAILED and %fail-cause, against REPORTED messages (severity, number, %element), and against data read back with READ ENTITIES. Tear down with ROLLBACK ENTITIES. Each test method should cover one behavior, with descriptive names such as "approve_rejected_in_status_new".
A useful checklist for what to test: each validation should have one passing and one failing case, including the message and the field it targets; each determination should be checked for a correct result and for idempotency, by triggering it twice and confirming the same result; each action should be tested in both allowed and disallowed states, checking the returned result and messages; feature control should be checked by confirming GET PERMISSIONS returns the expected enabled or disabled values per status; authorization should be run with a test user, or with test doubles for authority checks where the release supports them; draft should be tested by creating a draft (%is_draft = mk-on), changing it, executing Prepare and Activate, and verifying the active instance; bulk behavior should be tested with 100 to 500 instances in one call, checking for no failures and acceptable runtime; and cross-BO calls should have calls to other BOs replaced by test doubles, so that only your own logic is actually being tested.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.