Skip to content
Development
Skill

/sap-gen-abap-unit

Generates ABAP Unit tests for an EXISTING object (global class / function module / report) and closes the loop on a live system: pre-check the generated test, deploy, activate, run with coverage, read failures, fix, repeat until green (bounded). Reads the active source, builds a

From plugin
sap-dev
8123 skills3 agents
Install
$ npx -y skills add sapdev-ai/sap-dev --skill sap-gen-abap-unit --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/sap-gen-abap-unit

Context preview

The summary Claude sees to decide when to auto-load this skill.

Generates ABAP Unit tests for an EXISTING object (global class / function module / report) and closes the loop on a live system: pre-check the generated test, deploy, activate, run with coverage, read failures, fix, repeat until green (bounded). Reads the active source, builds a

SKILL.md

sap-gen-abap-unit.SKILL.md
name: sap-gen-abap-unit
description: |
  Generates ABAP Unit tests for an EXISTING object (global class / function module
  / report) and closes the loop on a live system: pre-check the generated test,
  deploy, activate, run with coverage, read failures, fix, repeat until green
  (bounded). Reads the active source, builds a call/data map, and runs a SEAM
  ANALYSIS that classifies every DB read and external call into a doubling strategy
  (OSQL test double for SELECTs, ABAP test double for injected dependencies, or
  flags untestable-without-refactor), then emits a test class honest about what it
  could and could not cover. Pairs with /sap-run-abap-unit (which runs the tests).
  Deploy is GUI (/sap-se24 --test-source CCAU for a class, /sap-se38 for a report
  test) and gated — asks before writing anything (Rule 2).
  Prerequisites: pinned /sap-login connection; active GUI session for class download
  + deploy + run; SAP NCo 3.1 for RFC source read.
argument-hint: "<OBJECT_NAME | path-to.abap> [--type class|fm|program|auto] [--target-coverage <n>] [--max-rounds 3] [--doubles auto|osql|none] [--deploy ask|yes|no] [--risk-level harmless|dangerous|critical] [--no-gui]"

SAP Generate ABAP Unit Tests Skill

You generate an ABAP Unit test class for an existing object, then **close the loop**: pre-check → deploy → activate → run-with-coverage → read failures → fix → repeat until tests pass and coverage meets the target (or you report honestly what is not testable without a refactor). The *generation* is your reasoning; the *deploy / activate / run / coverage* half reuses skills that are already live-tested.

This skill observes `shared/rules/skill_operating_rules.md`. **Rule 2 (no unsolicited deployment) applies**: generation is read-only, but the deploy/run loop writes a test artifact to SAP — it is gated behind `--deploy` (default `ask`).

Task: $ARGUMENTS

> **Vocabulary.** This is the `gen` half of the ABAP-unit pair: > `sap-gen-abap-unit` (you) generates → `/sap-run-abap-unit` runs. Same > "abap-unit" token on purpose.

---

Shared Resources

| File / token | Path | Purpose | |---|---|---| | `sap_settings_lib.ps1` | `<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_settings_lib.ps1` | settings merge | | `sap_connection_lib.ps1` | `<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1` | `Get-SapWorkDir`, `Get-SapCurrentSessionPath` | | `sap_object_resolver.ps1` | `<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_object_resolver.ps1` | type + TADIR identity | | `sap_rfc_read_source.ps1` | `<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_rfc_read_source.ps1` | `Read-SapAbapSource` (program/include/FM) | | `sap_explain_parse.ps1` | `<SAP_DEV_CORE_SHARED_DIR>\..\skills\sap-explain-object\references\sap_explain_parse.ps1` | source → `map.json` (units / externals / db reads+writes) — **drives the seam analysis** | | SE24 download VBS | `<SAP_DEV_CORE_SHARED_DIR>\..\skills\sap-se24\references\sap_se24_check_and_download.vbs` | class source (GUI) | | `sap_attach_lib.vbs` (`%%ATTACH_LIB_VBS%%`) | `<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_attach_lib.vbs` | `AttachSapSession` for the download VBS | | `abap_code_quality_rules.md` (§15) | `<SAP_DEV_CORE_SHARED_DIR>\rules\abap_code_quality_rules.md` | the ABAP Unit emission rules (`FOR TESTING DURATION SHORT RISK LEVEL HARMLESS`, `cl_abap_unit_assert=>assert_*`) | | `customer_brief.md` | `{custom_url}\customer_brief_<LANG>.md` → `{custom_url}\customer_brief.md` → built-in `_<LANG>` variant → built-in template (`<LANG>`: `userConfig.template_language` → `userConfig.sap_language` → `EN`) | `MODE_MIN_COVERAGE`, `MODE_OOP`, release, risk level | | `sap_log_helper.ps1` | `<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1` | structured logging |

**Skills this one orchestrates** (skills-first, per CLAUDE.md Rule 6 — invoke via the Skill tool, never re-implement): `/sap-check-abap`, `/sap-transport-request`, `/sap-se24` (`--test-source`), `/sap-se38`, `/sap-activate-object`, `/sap-run-abap-unit`.

`<SAP_DEV_CORE_SHARED_DIR>` = `plugins/sap-dev-core/shared` — 3 levels up from `<SKILL_DIR>`, then into `sap-dev-core\shared`.

---

Step 0 — Resolve Work Directory

powershell -NoProfile -ExecutionPolicy Bypass -Command ". '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_settings_lib.ps1'; . '<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_connection_lib.ps1'; Write-Output ('WORK_DIR=' + (Get-SapWorkDir)); Write-Output ('CUSTOM_URL=' + (Get-SapSettingValue 'custom_url' ((Get-SapWorkDir) + '\custom'))); Write-Output ('RUN_TEMP=' + (Get-SapRunTemp))"

Settings reads/writes follow `<SAP_DEV_CORE_SHARED_DIR>/rules/settings_lookup.md`. Set `{WORK_TEMP}` = `{work_dir}\temp`, `{OUT}` = `{WORK_TEMP}\aunit_gen\{OBJECT}`, and `{RUN_TEMP}` = the `RUN_TEMP=` value printed above (`Get-SapRunTemp` mints + creates a fresh per-run dir `{work_dir}\temp\run_<id>` — holds the log state file; mint once here and reuse the same value in Step 0.5 and Final).

cmd /c if not exist "{OUT}" mkdir "{OUT}"

---

Step 0.5 — Start Logging (best-effort)

powershell -ExecutionPolicy Bypass -File "<SAP_DEV_CORE_SHARED_DIR>\scripts\sap_log_helper.ps1" -Action start -StateFile "{RUN_TEMP}\sap_gen_abap_unit_run.json" -Skill sap-gen-abap-unit -ParamsJson "{\"target\":\"<OBJECT>\"}"

---

Step 1 — Parse Arguments

| Arg | Default | Notes | |---|---|---| | positional | — | Object name (uppercase) OR a `.abap` file path (FILE mode = generate from local source, no acquisition). | | `--type` | `auto` | `class` / `fm` / `program`. | | `--target-coverage <n>` | brief `MODE_MIN_COVERAGE` / `0` | Coverage % to drive the fix loop toward. | | `--max-rounds <n>` | `3` | Cap on generate→run→fix iterations. | | `--doubles <m>` | `auto` | `auto` = pick per dependency (Step 4); `osql` = force OSQL DB doubles; `none` = no doubles (pure-function tests only). | | `--deploy <m>` | `ask` | `ask` confirms before each write; `yes` runs the loop unattended; `no` generates + pre-checks only (no SAP write). | | `--risk

Read more
Ships withsap-dev

SAP development automation skills for AI coding assistants. Windows-only — the skills drive SAP GUI for Windows via GUI Scripting (plus optional RFC via SAP NCo); there is no macOS/Linux path.

Get the whole plugin

Other skills on sap-dev.