
Test attributes are meta properties of Test Classes, which are taken into account during test execution.
You can define the risk level and execution duration of unit tests.
Risk Level
The risk level ( RISK LEVEL) describes the effects that a test can have on the data security of the system.
The risk level could have one of the following values:
CRITICAL
The test could change system settings or the Customizing, for example.
DANGEROUS
The test could change persistent application data, for example.
HARMLESS
The test has no effect on persistent data or system settings.
For test execution, the maximum risk level is specified for which tests can be executed.
This definition takes place for the test execution in the ABAP Workbench using transaction SAUNIT_CLIENT_SETUP which is part of the Implementation Guide (IMG) but which can be executed directly.
This definition takes place using a dialog box to execute the test in the Code Inspector, where the Customizing setting restricts the options available for selection.
Subclasses of test classes can only raise the risk level of the superclass (for example, from harmless to dangerous).
Any attempts to reduce the risk level are ignored and trigger a warning when the test is executed. If a superclass already has an incorrect risk level, this flaw is inherited by its subclasses and is issued as a warning if the relevant tests are executed.
You must define a risk level for SAP test classes. The specification is checked when the test is executed.
Execution Duration
The execution duration ( DURATION) describes the expected duration of the execution of the class-defined test (execution of all test methods).
The execution duration could have one of the following values:
SHORT
Short - an imperceptibly short execution duration is expected. This is the default value.
MEDIUM
Medium - a noticeable execution duration is expected.
LONG
Long - a very noticeable execution duration is expected.
Specifying the Execution Duration prevents programming errors in the test methods, such as endless loops, resulting in excessively long test runs. If a test run exceeds the expected execution duration, the test is stopped.
The times stated above are guidelines, and must be adapted to suit the situation and condition of the relevant application server, depending on the hardware used. This is done using transaction SAUNIT_CLIENT_SETUP, which is part of the IMG implementation guide.
Specifying Test Properties
In systems with release < 7.00 enhancement pack 2 you specify the test properties of local test classes using pseudo comments.
Add the pseudo comments after the CLASS ... FOR TESTING statement. The pseudo comments have the following syntax:
CLASS ... FOR TESTING
"#AU Risk_Level Critical|Dangerous|Harmless
"#AU Duration Short|Medium|Long
You can specify one pseudo comment for each program row. To specify two test attributes for a test class, you must spread the CLASS statement across at least two lines.
The field is case-sensitive.
In systems with release 7.00 enhancment pack 2 or higher the statement additions RISK LEVEL and DURATION replace the pseudo comments of lower releases.
CLASS ... FOR TESTING
[RISK LEVEL {CRITICAL|DANGEROUS|HARMLESS}]
[DURATION {SHORT|MEDIUM|LONG}]
The test attributes of global test classes are defined in the Attributes of the class in the Class Builder.