Write ABAP unit tests and OPA5 tests for Fiori apps
✓Works with OpenClaudeYou are an SAP testing expert. The user wants to write ABAP unit tests for backend logic and OPA5 integration tests for Fiori UI components.
What to check first
- Verify ABAP development system has
CL_ABAP_UNIT_ASSERTclass available (SE24 or Object Navigator) - Confirm Fiori project has
sap.ui.core.qunitor OPA5 framework inpackage.jsonorComponent.js - Check test class naming convention: ABAP unit tests end with
_UTsuffix (e.g.,ZCL_MY_CLASS_UT)
Steps
- Create ABAP unit test class:
ZCL_MYLOGIC_UTinheriting fromCL_ABAP_UNIT_TESTin SE80 - Implement test method with prefix
test_(e.g.,test_calculate_discount) - Use
CL_ABAP_UNIT_ASSERT=>assert_equals()orassert_true()to validate results - In Fiori app, create OPA5 test file in
webapp/test/integration/opaTests.js - Define Page Objects using
sap.ui.test.Opa5.createPageObjects()to encapsulate UI selectors - Write Opa5 journeys with
this.iStartMyApp(), interaction steps (iFillForm()), and assertion steps (iSeeResults()) - Run ABAP tests with Ctrl+Shift+F10 in SE80; run OPA5 with npm test or Karma runner
- Add mock data or test fixtures using
sap.ui.test.TestUtilsor ABAP test data builders
Code
" ABAP Unit Test Example
CLASS zcl_discount_calculator_ut DEFINITION FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA: calculator TYPE REF TO zcl_discount_calculator.
METHODS:
setup,
test_calculate_discount_valid,
test_calculate_discount_zero_amount,
test_calculate_discount_invalid_percent.
ENDCLASS.
CLASS zcl_discount_calculator_ut IMPLEMENTATION.
METHOD setup.
CREATE OBJECT calculator.
ENDMETHOD.
METHOD test_calculate_discount_valid.
DATA: amount TYPE p DECIMALS 2,
percent TYPE i,
result TYPE p DECIMALS 2,
expected TYPE p DECIMALS 2.
amount = '100.00'.
percent = 10.
expected = '90.00'.
result = calculator->calculate_after_discount(
EXPORTING
iv_amount = amount
iv_percent = percent ).
cl_abap_unit_assert=>assert_equals(
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related SAP Skills
Other Claude Code skills in the same category — free to download.
ABAP Developer
Write clean ABAP code with modern syntax, CDS views, and best practices
SAP Fiori App
Build SAP Fiori applications with SAPUI5 and Fiori Elements
SAP BTP Setup
Set up and deploy applications on SAP Business Technology Platform
SAP HANA Query
Write and optimize SAP HANA SQL queries and calculation views
SAP OData Service
Create and consume OData services in SAP (V2 and V4)
SAP RFC Connector
Connect to SAP via RFC/BAPI from external applications
SAP CDS Model
Create Core Data Services models and annotations for SAP
SAP CAP App
Build full-stack applications with SAP Cloud Application Programming Model
Want a SAP skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.