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

CLASS - FOR TESTING

Short Reference

Syntax

CLASS class DEFINITION FOR TESTING [RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}]
                                   [DURATION   {SHORT|MEDIUM|LONG}].


Extras:

1. ... RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}

2. ... DURATION {SHORT|MEDIUM|LONG}

Effect

The FOR TESTING addition is used to defined a class as a test class for the ABAP Unit tool. Test classes can contain test methods that are called as individual tests during a test run.

A test class is usually a local class. The source code in a test class is not part of the production code of the program and is not generated in production systems (controlled using the profile parameter abap/test_generation). A test class and its components cannot be addressed in the production code of the program therefore, only in other test classes. In particular, a subclass of a test class must be a test class itself and be declared using the FOR TESTING addition. The only exception to this rule is that test classes can be specified as friends in the definition of production classes to make it possible to test private components.

A local test class can contain special private methods that implement the fixture for the tests of the class. These methods have the following predefined names:

Notes

Addition 1

... RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}

Addition 2

... DURATION {SHORT|MEDIUM|LONG}

Effect

These additions assign test properties to a test class. RISK LEVEL defines the risk level for a test and DURATION the expected execution time. The test properties are checked during when the test is executed.

Notes