Park testing knowledge files for later review

This commit is contained in:
Jeffrey Bulanadi 2026-06-15 07:55:26 +08:00
parent 822cae1b27
commit c4ecab140b
6 changed files with 167 additions and 0 deletions

View file

@ -0,0 +1,26 @@
---
bc-version: [all]
domain: testing
keywords: [testpermissions, permissions, restrictive, disabled, super, test-context, permission-set]
technologies: [al]
countries: [w1]
application-area: [all]
---
# TestPermissions attribute controls the permission set under which a test runs
## Description
The `TestPermissions` property on a test codeunit — or the `[TestPermissions]` attribute on an individual test function — controls which permission set the test executes under. When omitted, the test runs with the permissions of the calling user, typically SUPER in a development environment. Tests that pass under SUPER may fail for real users with standard permission sets.
## Best Practice
Set `TestPermissions = Restrictive` at the codeunit level. This runs every test with no permission sets assigned, catching missing `InherentPermissions` or `PermissionSet` grants before they reach production. Override at the function level with `[TestPermissions(TestPermissions::Disabled)]` only for tests that explicitly verify admin-level behavior.
See sample: `testpermissions-attribute-controls-test-context.good.al`.
## Anti Pattern
Omitting `TestPermissions` entirely, or setting `Disabled` at the codeunit level. Both cause every test to run as SUPER. Permission errors that real users would hit are invisible, and the test suite gives false confidence about the app's behavior under realistic conditions.
See sample: `testpermissions-attribute-controls-test-context.bad.al`.