ABAPCLASS_FOR_TESTING - CLASS FOR TESTING
Vendor Master (General Section) BAL Application Log DocumentationThis documentation is copyright by SAP AG.
CLASS - FOR TESTING
Syntax
... FOR TESTING [RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}]
[DURATION {SHORT|MEDIUM|LONG}] ... .
Additions
1. ... RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}
2. ... DURATION {SHORT|MEDIUM|LONG}
Effect
The FOR TESTING addition is used to defined a class as atest class for theABAP Unit tool. Test classes can containtest methods that are called during atest 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 theprofile parameterabap/test_generation). A test class and itscomponents 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 asfriends 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 thefixture for the tests of the class. These methods have the following predefined names:
- An instance method setup, which is executed before every test of the class.
- An instance method teardown, which is executed after every test of the class.
- A static method class_setup, which is executed once before all tests of the class.
- A static method class_teardown, which is executed once after every test of the class.
Notes
- In addition to the test methods and special methods for the fixture, a test class can also contain othercomponents. These components can be used in your own test class only or in other test classes, depending on the visibility. In this way you can define help methods for tests, for example.
- Test classes can inherit from any other classes, in particular from global classes. This allows you to implement general global tests that can be used in local test classes.
- From Release 7.0, you can create global test classes to reuse elaborately prepared tests. Global testclasses should always be abstract and can only be used in local test classes. Currently, all instance methods of a global test class are automatically test methods.
- You cannot use the addition FOR TESTING in a local class that is created in the area for local types of the class pool of a global test class. The addition is not needed in auxiliaryclasses for the global test class, since its property test classhas an effect on the entire class pool with regard to its generation. In rare cases in which a globaltest class is to be tested itself, local test classes can be created as recommended for other global classes in the area local test classes.
Addition 1
... RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}
Addition 2
... DURATION {SHORT|MEDIUM|LONG}
Effect
These additions assign testproperties to a test class. RISK LEVEL defines the risk level for a test and DURATIONthe expected execution time. The test properties are checked during when the test is executed. Testswhose risk level is higher than allowed in a system are not executed. Tests that run longer than the expected execution time are terminated.
Notes
- You must define a risk level for SAP test classes.
- The additions RISK LEVEL and DURATION replace thepseudo comments for test classes. Existing pseudo comments are not ignored, but you should no longer use them.
SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up Fill RESBD Structure from EBP Component Structure
This documentation is copyright by SAP AG.
Length: 6302 Date: 20120518 Time: 204617 triton ( 233 ms )






