Skip to content

Require Explicit DURATION and RISK LEVEL Attributes on Test Classes ​

WarningClean ABAP & Modern Syntax#EC PREF_TEST_ATTRRemote Enabled

Overview ​

Require DURATION and RISK LEVEL attributes on test classes.

ATC Finding Message: Test class must declare DURATION and RISK LEVEL attributes

Rationale ​

ABAP Unit test classes (FOR TESTING) should declare explicit DURATION (SHORT, MEDIUM, or LONG) and RISK LEVEL (HARMLESS, DANGEROUS, or CRITICAL) attributes on their CLASS ... DEFINITION statement. Without explicit attributes, the test runner assigns default values that may cause tests with external dependencies or database commits to execute in restricted test environments or time out prematurely.

Best Practice: Always declare DURATION SHORT RISK LEVEL HARMLESS for fast, hermetic unit tests.

Non-Compliant ​

abap
" Anti-pattern: Test class without duration or risk level attributes
CLASS lcl_order_test DEFINITION FOR TESTING.
  PUBLIC SECTION.
    METHODS test_calculation FOR TESTING.
ENDCLASS.

Compliant ​

abap
" Clean ABAP: Explicit duration and risk level declaration
CLASS lcl_order_test DEFINITION FOR TESTING
  DURATION SHORT
  RISK LEVEL HARMLESS.
  PUBLIC SECTION.
    METHODS test_calculation FOR TESTING.
ENDCLASS.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault ValueDescription & Guidance
CHECK_DURATIONBooleantrueRequire explicit DURATION attribute (SHORT, MEDIUM, LONG)
CHECK_RISK_LEVELBooleantrueRequire explicit RISK LEVEL attribute (HARMLESS, DANGEROUS, CRITICAL)

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC PREF_TEST_ATTR

" SAP CI_ prefix format:
... "#EC CI_PREF_TEST_ATTR

Technical Details ​

Released under the MIT License.