← ClaudeAtlas

abap-unit-testinglisted

Help with ABAP Unit testing including test class setup, assertions, test doubles, mocking frameworks, dependency injection, CDS test environments, SQL test environments, RAP BO test doubles, and test fixtures. Use when users ask about ABAP unit tests, test classes, test methods, CL_ABAP_UNIT_ASSERT, test doubles, mocking, CDS test environment, SQL test environment, RAP testing, ABAP test injection, test seams, behavior-driven testing, TDD in ABAP, test isolation, or writing automated tests for ABAP code. Triggers include "write a unit test", "create test class", "mock a dependency", "test a CDS view", "test a RAP BO", "test double", "assertion", "test fixture", "test isolation", or "ABAP unit".
williamcorrea23/sap-router-skill · ★ 1 · Testing & QA · score 66
Install: claude install-skill williamcorrea23/sap-router-skill
# ABAP Unit Testing Guide for writing effective ABAP Unit tests including test class setup, assertions, test doubles, mocking frameworks, and test environments for CDS, SQL, and RAP. ## Workflow 1. **Determine the testing goal**: - Testing business logic in a class method - Testing a CDS view entity - Testing a RAP BO behavior implementation - Testing database-dependent logic with SQL test doubles - Setting up test doubles for external dependencies 2. **Choose the right approach**: - Direct unit test for pure logic (no dependencies) - Constructor/setter injection for mockable dependencies - CDS test environment for CDS view tests - OSQL test environment for SQL-dependent code - RAP BO test doubles for RAP behavior tests 3. **Follow the AAA pattern**: Arrange → Act → Assert 4. **Ensure test isolation**: Tests must not depend on persistent data or external systems ## Test Class Fundamentals ### Test Class Definition ```abap "! Test class for ZCL_MY_CLASS CLASS ltc_my_class DEFINITION FINAL FOR TESTING DURATION SHORT RISK LEVEL HARMLESS. PRIVATE SECTION. DATA cut TYPE REF TO zcl_my_class. "Class Under Test CLASS-METHODS class_setup. "Once before all tests CLASS-METHODS class_teardown. "Once after all tests METHODS setup. "Before each test METHODS teardown. "After each test METHODS test_calculate_total FOR TESTING. METHODS test_validate_input FOR TESTING. METHODS test_emp