Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  program editing →  Testing and Checking Programs 

ABAP Unit

ABAP Unit is a test framework for unit tests. ABAP Unit can be used to:

  • run single tests or mass tests
  • evaluate test results

Single texts can be started directly in the tool for the program in question. More comprehensive test runs are executed from ABAP Unit Browser in ABAP Workbench or by using ABAP Test Cockpit. ABAP Unit is closely associated with Coverage Analyzer, enabling test coverage to be measured as well.

In ABAP programs, unit tests are performed as test methods in local test classes. They are not part of the production code of a program, but are transported in the same way. Test methods of this type are executed and evaluated using ABAP Unit Framework. The test methods generally call the tested units of the production code and then check the results using methods of the class CL_ABAP_UNIT_ASSERT. Test classes and test methods are defined using the following language elements. Special test includes are used to define test classes in class pools and function groups.

If test classes implement interfaces, not all interface methods generally need to be implemented there. The error message or warning that otherwise occurs can be hidden in test classes by using an addition of the statement INTERFACES.

If production code contains parts that are not suitable for unit tests, sections of code can be flagged as test seams. Injections can be defined in methods of test classes. Injections replace the test seams with test-friendly code when a unit test is executed.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • All components required for tests in the context of ABAP Unit should be defined exclusively in test classes. This ensures that they are not generated in production systems and cannot be addressed by production code. Alongside test classes with test methods, this also includes test dummies and other helper classes that do not contain test methods.

  • The new syntax @testing ... in ABAP Doc comments associates test classes and test methods with repository objects. This makes it possible to display and execute these classes and methods in the ADT of the repository objects.

  • For more information, see the ABAP Unit documentation on SAP Help Portal.

Continue

CLASS - FOR TESTING

METHODS - FOR TESTING

INTERFACES - PARTIALLY IMPLEMENTED

Test Seams