PackagePackagetypeA library you install and call yourself.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

regression_test

A snapshot library for ABAP that records a value once and compares against it on every later run, from either the debugger or a unit test, storing snapshots in eCATT test data containers.

Snapshot testing in ABAP: a value is recorded once, trusted as correct, and later runs are compared against it. Inside a unit test that is class zdbgl_snapshots_tdc, whose compare_or_record either compares the value it is given with the recorded one or records it, each value under a unique name, with the SET/GET parameter ZDBGL_SNAP_RECORD deciding which; the snapshot is stored in an eCATT test data container and compared through cl_abap_unit_assert=>assert_equals unless the compare method is overridden. The other route is the debugger script zdbgl_script_store_in_tdc, which writes a snapshot at a breakpoint into a test data container that already exists, and a unit test then reads it back with cl_apl_ecatt_tdc_api; the README gives this as the way around the COMMIT WORK that updating a snapshot from a unit test issues. A legacy API that kept debugger snapshots in the database tables zdbgl_variables and zdbgl_locals is documented separately, in the repository's docs folder.

Facts

Last pushLicenceMIT

Where it sits

Lives in
Provides
Unit testingABAPUnit testingcapabilityTesting application logic without a running business process — and the test doubles that make dependencies on the database and on framework services tractable.
Requires
ABAP-LoggerABAP-LoggerartifactDisplays interactive messages; the README lists it under its own Dependencies heading, with no condition stated.abapGitabapGitartifactInstalls the repository into the ABAP system; the README gives abapGit as the only installation route.

Who is behind it

Johannes GerbershagenJohannes GerbershagenPersonMaintains this
In the atlas: maintains 1, contributes to 7
@germanysources
maintainer

Before choosing this

Signals

ActivityQuietNo published releases; repository quiet for 28 months

It publishes no releases, and its repository has been quiet for at least 24 full months. This may be normal for stable software; check whether its current state still fits your use.

Conditions

PracticalFunctional boundary

Values the test data container cannot hold: references of any kind, complex structures, and tables whose line type is a complex structure or another table. Structures must be defined in the ABAP Dictionary, so one declared locally cannot be stored at all.

What it declares

Every artifact

Type
Package
Origin
Independently maintained

As a package

Where it runs
Inside its host
Distributed through
abapGit

Connections3

README

quoted from germanysources/regression_test under MIT, read
germanysources/regression_test/README.mdOn GitHub

Snapshots in ABAP

Snapshots

Create snapshots either in the debugger or directly in your unit-tests. Snapshots are stored in ECATT test data containers (TDC).

Unit-Test

Snapshots can be created with class zdbgl_snapshots_tdc. The following listing shows a sample unit-test using snapshots.

CLASS test_snapshot DEFINITION FOR TESTING
  DURATION SHORT RISK LEVEL HARMLESS.

  PRIVATE SECTION.

    METHODS flight_test FOR TESTING
      RAISING zcx_dbgl_snapshot.

ENDCLASS.

CLASS test_snapshot IMPLEMENTATION.

  METHOD flight_test.

    DATA(snapshot_manager) = zdbgl_snapshots_tdc=>create_default(
      tdc_name = 'ZDBGL_SNAPSHOT_SAMPLE'
    ).

    DATA(carrier) = VALUE scarr_tab(
      ( carrid = 'SAP' carrname = 'SAP Flights' )
      ( carrid = 'IN' carrname = 'Internat. Airways' )
    ).
    DATA(flight) = VALUE sflight( carrid = 'SAP' connid = 700 fldate = '20201231' ).

    snapshot_manager->compare_or_record( name = 'CARRIER' actual = carrier ).
    snapshot_manager->compare_or_record( name = 'FLIGHT' actual = flight ).

    " can be omitted, when autosave = abap_true in factory method or constructor
    snapshot_manager->commit_changes( ).

  ENDMETHOD.

ENDCLASS.

The method snapshot_manager->compare_or_record compares the given value with the recorded value or records the value. We need to give every value a unique name in the parameter name. The behavior (recording or comparing) is controlled with the SET/GET-parameter ZDBGL_SNAP_RECORD. A value of 'X' means 'create/update the snapshot'. Parameter ZDBGL_SNAP_RECORD

Comparison

The standard implementation uses the method cl_abap_unit_assert=>assert_equals for comparison. Override the method zdbgl_snapshots_tdc=>compare to specify another comparison method.

Restrictions
  • Structures must be defined in the ABAP dictionary. Structures defined outside of the ABAP dictionary can't be stored in test data containers.
  • Any kind of references (pointing to classes, interfaces or data objects) are not supported
  • Updating a snapshot closes the SAP-LUW with COMMIT WORK. To avoid this, use debugger snapshots as described in the next section.

Debugger

Create snapshots

Another option to create snapshots is the debugger script zdbgl_script_store_in_tdc. Prerequisite is an existing TDC.

Prerequisite step: create ECATT test data container

Go the transaction secatt and create a test data container. Add a parameter for every variable you want to record. The parameter should have the same name and type as the variable. Last but not least give the test data container API access as shown in the picture below. Permit api access

Before the modification

Set an appropriate breakpoint and create the snapshot with the debugger-script zdbgl_script_store_in_tdc. Load script This script asks you for the name, the version and the variant of the test data container as shown in the picture below. Prompt tdc key

Writing unit-tests

With the API in the class cl_apl_ecatt_tdc_api we can access the snapshot.

Example

The example can be found in the program zdbgl_demo_regression_test.

The procedure to_verify is the procedure under test.

FORM to_verify.
  FIELD-SYMBOLS: <line> TYPE sflight.

  APPEND INITIAL LINE TO demo_itab ASSIGNING <line>.
  <line>-carrid = 'LH'.
  <line>-connid = '3444'.
  <line>-price = 400.

ENDFORM.

In the first step we create a snapshot before and after this procedure is executed.

In the second step we use the snapshot (test data container "ZDBGL_SAMPLE") to write unit-tests:

REPORT ZDBGL_DEMO_REGRESSION_TEST.
DATA: demo_itab TYPE STANDARD TABLE OF sflight.

START-OF-SELECTION.
  FIELD-SYMBOLS: <line> TYPE sflight.

  APPEND INITIAL LINE TO demo_itab ASSIGNING <line>.
  <line>-carrid = 'LH'.
  <line>-connid = '3445'.
  <line>-price = 500.
  BREAK-POINT. "snapshot is created
  PERFORM to_verify.
  BREAK-POINT. "snapshot is created


" subprogram should be verified.
" It changes the global variable demo_itab.
FORM to_verify.
  FIELD-SYMBOLS: <line> TYPE sflight.

  APPEND INITIAL LINE TO demo_itab ASSIGNING <line>.
  <line>-carrid = 'LH'.
  <line>-connid = '3444'.
  <line>-price = 400.

ENDFORM.

CLASS regression_test DEFINITION FOR TESTING
  DURATION SHORT RISK LEVEL HARMLESS.

  PRIVATE SECTION.
    DATA: tdc_accessor TYPE REF TO cl_apl_ecatt_tdc_api.

    METHODS setup
      RAISING cx_static_check.

    METHODS verify_changed_itab FOR TESTING
      RAISING cx_static_check.

ENDCLASS.

CLASS regression_test IMPLEMENTATION.

  METHOD setup.

    tdc_accessor = cl_apl_ecatt_tdc_api=>get_instance( EXPORTING
      i_testdatacontainer = 'ZDBGL_SAMPLE' i_testdatacontainer_version = 1 ).

  ENDMETHOD.

  METHOD verify_changed_itab.
    DATA: exp_demo_itab LIKE demo_itab.

    " given: use the snapshot before procedure under test was executed
    tdc_accessor->get_value( EXPORTING i_param_name = 'DEMO_ITAB' i_variant_name = 'BEFORE'
      CHANGING e_param_value = demo_itab ).

    " when: execute procedure under test
    PERFORM to_verify.

    " then: use the snapshot after the procedure under test was executed
    tdc_accessor->get_value( EXPORTING i_param_name = 'DEMO_ITAB' i_variant_name = 'AFTER'
      CHANGING e_param_value = exp_demo_itab ).
    cl_abap_unit_assert=>assert_equals( exp = exp_demo_itab
     act = demo_itab msg = 'Regression test not passed' ).

  ENDMETHOD.

ENDCLASS.
Restrictions

These types are currently supported:

  • simple types (like characters, strings, integer)
  • flat structures (complex structures containing components with tables or structures are not supported)
  • tables with a flat structure or a simple type as the table line type

These types are not supported:

  • all form of references
  • complex structures
  • tables with complex structures as the table line type or with tables as the table line type
Legacy API

There is a legacy API to create snapshots in the debugger, which uses the database tables zdbgl_variables and zdbgl_locals as a temporary storage and which is bit more difficult to use. This API is documented in the docs-folder.

Installation

Installation is done with abapGit. ABAP 7.40 or higher is needed. All ABAP-objects have the prefix zdbgl.

Logs

Exceptions are logged in the checkpoint-groups "zdbgl_store_globals" and "zdbgl_store_locals" (see transaction saab). Logging is only active, if the checkpoint-groups is activated.

Dependencies

MIT, read
Unit testing
  1. abap2UI5 headless frontendDrives abap2UI5 app classes from ABAP Unit tests
  2. @abap2ui5/mcp-serverMCP server for the abap2UI5 check, deploy and run loop
  3. assertFluent assertion helper for ABAP Unit tests
  4. @abaplint/transpilerTranspiles ABAP to JavaScript to run on Node.js
  5. Modernization Agents for SAP on AWSAWS agents for ABAP, PI/PO and BW modernisation work
  6. abap_db_preparatorReplays stored database snapshots in ABAP unit tests
  7. cacamber-BDD-for-ABAPBDD framework turning Given/When/Then into ABAP Unit steps
  8. abap-utesthelpHelper classes for ABAP Unit tests and test doubles
  9. abapCovUploads ABAP Unit code coverage to codecov.io
  10. ABAP remote filesystemVS Code extension editing ABAP systems over ADT as a filesystem
  11. open-steamgateLocal ABAP server serving /IWBEP/ OData v2 without an SAP system
  12. express-icf-shimShim running an ABAP ICF handler behind an Express 4.x server
  13. open-abap-coreCore ABAP artifacts for code transpiled by @abaplint/transpiler
  14. mockup_loaderLoader of Excel-prepared ABAP unit test data, with stub generation
  15. mockAA free mocking framework for ABAP, published under the Apache License 2.0.
  16. Vise_for_ABAPA characterisation-test helper: `ZCL_VISE=>GRIP` records a field's value once and fails a later run if it has changed.
  17. abap-senchaBDD/TDD assertion library for ABAP Unit, styled after Chai.js
  18. abap-test-containerGitHub-hosted test data container for ABAP Cloud
  19. abap-unit-runnerApplication job that runs and schedules ABAP Unit tests in the cloud
  20. adash-servicesBackend exposing ABAP Unit runs and coverage over REST and OData

Details

Sources3
Added by handdiscovered herechecked
github.com/germanysources/regression_testtree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
discovered viaAdded by hand
first seen in the atlas
ecosystem and domainabap, developer-experience
abaplint
issues under its own abaplint configuration1,410
lines3,895
statements2,184
objects44
files65
analysed, master
abaplint version2.120.84
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:germanysources-regression-test
JSON
/artifacts/germanysources-regression-test.json
MCP
Connecting an agent