$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
SAPintermediateNew

SAP Unit Test

Share

Write ABAP unit tests and OPA5 tests for Fiori apps

Works with OpenClaude

You 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_ASSERT class available (SE24 or Object Navigator)
  • Confirm Fiori project has sap.ui.core.qunit or OPA5 framework in package.json or Component.js
  • Check test class naming convention: ABAP unit tests end with _UT suffix (e.g., ZCL_MY_CLASS_UT)

Steps

  1. Create ABAP unit test class: ZCL_MYLOGIC_UT inheriting from CL_ABAP_UNIT_TEST in SE80
  2. Implement test method with prefix test_ (e.g., test_calculate_discount)
  3. Use CL_ABAP_UNIT_ASSERT=>assert_equals() or assert_true() to validate results
  4. In Fiori app, create OPA5 test file in webapp/test/integration/opaTests.js
  5. Define Page Objects using sap.ui.test.Opa5.createPageObjects() to encapsulate UI selectors
  6. Write Opa5 journeys with this.iStartMyApp(), interaction steps (iFillForm()), and assertion steps (iSeeResults())
  7. Run ABAP tests with Ctrl+Shift+F10 in SE80; run OPA5 with npm test or Karma runner
  8. Add mock data or test fixtures using sap.ui.test.TestUtils or 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

Quick Info

CategorySAP
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
saptestingabap-unit

Install command:

curl -o ~/.claude/skills/sap-unit-test.md https://clskills.in/skills/sap/sap-unit-test.md

Related SAP Skills

Other Claude Code skills in the same category — free to download.

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.