Monday, 19 June 2023

Manage Apex Access for Package Version Creation Tests

 Sometimes the Apex tests that you write require a user to have certain permission sets or permission set licenses. Use the apexTestAccess setting to assign permission sets and permission set licenses to the user in whose context your Apex tests get run at package version creation.

Its very important step to include "apexTestAccess" if we are not using System.runas() in test methods for generating 2GP packages.



"packageDirectories": [

    {

        "path": "force-app",

        "package": "TestPackage", 

        "versionName": "ver 0.1",

        "versionNumber": "0.1.0.NEXT",

        "default": true, 

        "unpackagedMetadata": {

            "path": "my-unpackaged-directory"

        },

        "apexTestAccess": {

               "permissionSets": [

                   "Permission_Set_1",

                   "Permission_Set_2"

               ],

               "permissionSetLicenses": [

                   "SalesConsoleUser"

               ]

           }


    }, 

]

Reference:

https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_unlocked_pkg_unpackaged_md.htm

No comments:

Post a Comment

Agentforce metadata types for deployment

 Hi, The following are key metadata types to consider when deploying Prompt Templates, Topics, Agent Actions, and Agents in Salesforce. <...