FAQ
Why does my test fail with “No such column ‘Foo__c’ on entity ‘Bar’” when the field exists in force-app?
Custom fields are loaded into the schema, but Salesforce field-level security (FLS) still applies. By default, aer test runs as a user with the System Administrator profile, which does not automatically grant access to custom objects or custom fields. SOQL queries that reference them fail just as they would in a real org without explicit permissions.
Grant the appropriate permissions to the test user with --assign-perms:
aer test force-app --assign-perms My_Permission_SetThe argument is the developer name of a permission set in your source tree (e.g., force-app/main/default/permissionsets/My_Permission_Set.permissionset-meta.xml). The flag is repeatable; pass each permission set the suite needs:
aer test force-app \
--assign-perms My_Permission_Set \
--assign-perms Admin_ExtrasFor permission sets in a managed package, load the package and qualify the name with the namespace prefix:
aer test force-app \
--package mypkg.pkg \
--assign-perms mypkg__AdminLonger term, consider updating your tests to use System.runAs to execute the
tests as a user explicitly granted the necessary permissions.