trm-dependencies

Tests and sample objects for dependency tracking

Version
1.0.0
License
Unspecified
Downloads
0

Maintainers

simonegaffurini

README

# trm-dependencies

`trm-dependencies` is a  package that ships an ABAP repository corpus for testing dependency recognition in [trm-server](https://github.com/RegestaItalia/trm-server).

The package contains sample objects for many SAP Workbench object types. Each sample is built to express one specific dependency on another repository object. ABAP Unit test classes then ask the trm-server dependency API for each sample's dependencies and check that the expected ones are found.

Use it to:

- check that the trm-server dependency handlers recognize the dependencies of each supported object type;
- catch regressions when a handler or the shared mapping framework changes;
- give a reference example of what each object type can depend on.

> [!WARNING]
> This is a test corpus, not application content. It installs many sample objects into the target system, such as enhancements, BAdI implementations, CMOD projects, ICF nodes, authorization objects and number range objects. Install it only on development or sandbox systems.

## Installation

```sh
trm install trm-dependencies
```

trm-server must already be installed on the target system. The test classes call the `/ATRM/` dependency API.

The package deliberately does not declare a dependency on trm-server. It is the base for building and validating new trm-server releases: the tests run against whichever trm-server version is installed, including a development build that hasn't been released yet. If the package required a specific published release, that would defeat its purpose and could pull in a different trm-server version than the one being tested. Install or update trm-server yourself before installing this package.

## Contents

| Package | Contents |
| --- | --- |
| `/ATRM/DEPENDENCIES` | Primary samples, named `/ATRM/` (for example `/ATRM/CLAS1`, `/ATRM/TABL2`). Each sample covers one dependency mechanism of its object type. |
| `/ATRM/DEVC1` … `/ATRM/DEVC5` | Sample packages, one per `DEVC` dependency mechanism: superpackage, use access, application component, default interface and switch assignment. |
| `/ATRM/DEPENDENCIES_AUX` | Auxiliary objects. They exist only as dependency targets for the primary samples, for example a function group called by a sample class. |
| `ZTRM_DEPENDENCIES` | Samples of object types that cannot use the `/ATRM/` namespace, or whose name is too long for it (for example some `SICF`, `TOBJ`, `TYPE` and `SUSC` objects). |
| `/ATRM/DEPENDENCIES_TESTS` | One ABAP Unit test class per object type, named `/ATRM/CL__DEP_TESTS`. |

Some object types cannot be created directly because SAP generates them or creates them from a parent editor (for example the classes generated for change documents, BAdIs and Gateway projects). The package includes these generated objects as SAP produces them.

## How the tests work

Each sample is designed around one relationship:

```text
source object type -> target object type -> dependency mechanism
```

Examples are a class implementing an interface, a data element using a domain, a CDS view reading a table, a transaction calling a program, or a package declaring use access to another package.

Each test method reads the dependencies of one sample through the trm-server dependency API and checks that the expected `TADIR` key is in the result:

```abap
DATA ls_object       TYPE /atrm/object.
DATA lt_dependencies TYPE /atrm/object_dependency_t.

ls_object-object   = 'CLAS'.
ls_object-obj_name = '/ATRM/CLAS1'.

/atrm/cl_object_dispacher=>get(
  key = ls_object
)->get_dependencies(
  IMPORTING dependencies = lt_dependencies
).

READ TABLE lt_dependencies
  WITH KEY tabname = 'TADIR'
           tabkey  = expected_tabkey
  TRANSPORTING NO FIELDS.

cl_abap_unit_assert=>assert_subrc( ).
```

Object types that cannot depend on anything get a baseline sample. Its test checks that no dependency is reported.

A failing test means that trm-server did not recognize a dependency that the sample really has. The fix belongs in the matching trm-server dependency handler, not in the sample.

## Running the tests

Run ABAP Unit on package `/ATRM/DEPENDENCIES_TESTS` to test every object type. To test one object type, run its class `/ATRM/CL__DEP_TESTS`. You can start the tests from ADT, SE80 or the ABAP Test Cockpit.

## Notes

- Not every SAP system release supports every sample object type. If an object type is missing on the target system, its samples cannot be imported.