abap-unit-testing
Skill0 starsChanged 3 months agoMITView on GitHub
Pruebas unitarias en ABAP: clases de test, asserts, test doubles/mocking, aislamiento de dependencias y cobertura. Úsala cuando el usuario escriba pruebas ABAP Unit, use CL_ABAP_UNIT, test doubles, o pida hacer testeable un código.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- dovoanhtruong/abap-agent-claudecode-workspacetheir own version, first seen Oct 12, 2026
- likweitan/abap-skillstheir own version, first seen Jul 14, 2026
- williamcorrea23/sap-router-skilltheir own version, first seen Jul 13, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- likweitan/abap-skills★ 72same name
- dovoanhtruong/abap-agent-claudecode-workspace★ 3same name
- williamcorrea23/sap-router-skill★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- abap-cloud-migrationSkill
- abap-cloudSkill
- abapgitSkill
- abap-sql-amdpSkill
- atc-cloudificationSkill
- authorization-iamSkill
- cds-view-entitiesSkill
- clean-abapSkill
- odataSkill
- rap-business-eventsSkill
- rapSkill
- released-abap-classesSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 91
No dejes que un test dependa de datos modificados por otro: cada test parte de un estado limpio (setup/teardown).
- Very specific: line 92
No pongas riesgo HARMLESS a un test que escribe en base de datos: úsalo con DANGEROUS y prefiere doblar la persistencia.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ABAP Unit Testing
Guía para escribir pruebas unitarias con ABAP Unit: clases de test aisladas, asserts, test doubles para desacoplar dependencias, y diseño testeable.
Cuándo y cómo usarla
- Identifica el objetivo: cubrir una lógica de negocio nueva, blindar un refactor o hacer testeable un código acoplado.
- Sitúa el contexto: define la unidad más pequeña que produce un resultado comprobable y sus dependencias (base de datos, otras clases) que habrá que doblar.
- Aplica el ciclo: escribe primero la especificación de test (idealmente antes del código), aísla dependencias con test doubles, y ejecuta con cobertura.
Clase de test y método FOR TESTING
Una clase se convierte en clase de test con la adición FOR TESTING; cada método de prueba también la lleva. Sin esa adición, es una clase ABAP normal.
CLASS ltc_price_calculator DEFINITION FINAL FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA cut TYPE REF TO zcl_price_calculator. " code under test
METHODS setup.
METHODS calculate_total FOR TESTING.
METHODS empty_gives_zero FOR TESTING.
ENDCLASS.
CLASS ltc_price_calculator IMPLEMENTATION.
METHOD setup.
cut = NEW #( ).
ENDMETHOD.
METHOD calculate_total.
DATA(result) = cut->calculate_total( base = 100 discount = 10 ).
cl_abap_unit_assert=>assert_equals(
exp = 90
act = result
msg = 'Descuento del 10% mal aplicado' ).
ENDMETHOD.
ENDCLASS.- Risk Level:
HARMLESS(no toca datos persistentes, por defecto),DANGEROUS(modifica datos),CRITICAL(modifica customizing). El sistema ignora tests con riesgo superior al permitido en el cliente. - Duration:
SHORT(<1 min, por defecto),MEDIUM(1-10 min),LONG(>10 min).
Asserts con CL_ABAP_UNIT_ASSERT
La clase de servicio CL_ABAP_UNIT_ASSERT compara valor esperado y real y decide si el test pasa.
cl_abap_unit_assert=>assert_equals( exp = expected act = actual msg = '...' ).
cl_abap_unit_assert=>assert_initial( act = table ).
cl_abap_unit_assert=>assert_not_initial( act = result ).
cl_abap_unit_assert=>assert_true( act = flag ).
cl_abap_unit_assert=>fail( 'No debería llegar aquí' ).Test doubles: aislar dependencias
La clave de una prueba unitaria es el aislamiento: no debe tocar la base de datos ni otras clases reales. Se inyecta un doble a través de una interfaz (inyección por constructor).
" Doble de la dependencia de datos
CLASS ltd_customer_stub DEFINITION FOR TESTING.
PUBLIC SECTION.
INTERFACES zif_customer_reader.
ENDCLASS.
CLASS ltd_customer_stub IMPLEMENTATION.
METHOD zif_customer_reader~get_discount.
result = '10'. " valor controlado por el test
ENDMETHOD.
ENDCLASS.
" En el test: inyectar el doble en lugar de la implementación real
METHOD setup.
DATA(stub) = NEW ltd_customer_stub( ).
cut = NEW zcl_price_calculator( customer_reader = stub ).
ENDMETHOD.Para dependencias sobre CDS/base de datos, RAP ofrece además frameworks de test double (cl_cds_test_environment, cl_osql_test_environment) que permiten insertar datos de prueba sin tocar tablas productivas.
Buenas prácticas y errores comunes
- Diseña para testear: si un método es difícil de probar, casi siempre está haciendo demasiado o depende de estado global. Extrae e inyecta dependencias por interfaz.
- Una prueba, una razón para fallar: métodos de test pequeños y con nombre que describe el escenario.
- No dejes que un test dependa de datos modificados por otro: cada test parte de un estado limpio (
setup/teardown). - No pongas riesgo
HARMLESSa un test que escribe en base de datos: úsalo conDANGEROUSy prefiere doblar la persistencia. - Ejecuta las pruebas de forma continua durante el desarrollo, no solo al final: detectan regresiones en la fase más barata de corregir.
Referencias
- Cursos y másters SAP de Logali Tech: https://logalitech.com/masters
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

