I've created a new 2GP package. Since it is going to be released to AppExchange, I've implemented a generic CRUD and FLS check for every place I contact with the Database in my Apex code.
I build a new package version with
-c key for Apex test coverage, but the tests fail due to FLS permission checks. CRUD checks pass just fine.
From the documentation, 2GP build goes this way:
- A new inaccessible scratch org is created.
- Metadata is pushed to the scratch org.
- Tests run.
- The post-install script runs.
So I don't see a way to assign FLS permissions to the user on behalf of who the tests are running.
Building a package without
-c or without FLS checks works perfectly.
Is there a way to overcome this FLS check, give FLS access to the running user or any other solution?