code pal for ABAP > DB Access in Unit Tests Check
The Check identifies database operations within the test classes.
The Check behaves differently depending on the test class classification (RISK LEVEL
) and automatically exempts the finding if a known test framework is find.
The Check reports:
SELECT
INSERT
UPDATE
MODIFY
DELETE
ROLLBACK
COMMIT
ALTER
The Check reports:
UPDATE
MODIFY
DELETE
ALTER
In short, the Check allows:
SELECT
INSERT
COMMIT
ROLLBACK
The Check identifies if the test class uses one of the following objects internally and exempts the finding automatically.
The relevant objects for the automatic exemption are:
IF_OSQL_TEST_ENVIRONMENT
CL_OSQL_TEST_ENVIRONMENT
IF_CDS_TEST_ENVIRONMENT
CL_CDS_TEST_ENVIRONMENT
Please, isolate the database dependency using one of the below frameworks:
In special cases, it is possible to suppress a finding by using the pseudo comment "#EC DB_ACCESS_UT
.
The pseudo comment must be placed right after the DB access statement.
SELECT * FROM tadir INTO TABLE @DATA(entries). "#EC DB_ACCESS_UT