code pal for ABAP > Documentation > DB Access in Unit Tests Check
The check searches for database operations inside ABAP Unit test classes that do not use an SQL test double framework to mock the database. Unit tests should usually be isolated from the actual database.
The check behaves differently depending on the test class's risk level:
The check reports:
SELECT
INSERT
UPDATE
MODIFY
DELETE
ROLLBACK
COMMIT
ALTER
The check reports:
UPDATE
MODIFY
DELETE
ALTER
If an instance of one of the following types associated with a test double framework is used in the test class, no findings are reported for database accesses:
IF_OSQL_TEST_ENVIRONMENT
CL_OSQL_TEST_ENVIRONMENT
IF_CDS_TEST_ENVIRONMENT
CL_CDS_TEST_ENVIRONMENT
Isolate the database dependency using one of the test double frameworks for SQL and CDS accesses:
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 statement that accesses the database.
SELECT * FROM tadir INTO TABLE @DATA(entries). "#EC DB_ACCESS_UT