0

we have one test class on execution process builder is getting fired. is there any way where I can avoid to run process builder while running test class.

3

You can use hierarchy custom setting in process builder to skip execution of process builder.

e.g. Create a hierarchy custom setting named AutomationSettings__c. Create a checkbox field SkipProcessBuilder__c. In process builder add first criteria with formula evaluates to true.

NOT($Setup.AutomationSettings__c.SkipProcessBuilder__c)

In test class insert this custom setting with SkipProcessBuilder__c value true in @testSetup method

AutomationSettings__c settings = new AutomationSettings__c(SetupOwnerId=UserInfo.getOrganizationId(), SkipProcessBuilder__c= true);
insert settings;
| improve this answer | |
0

You cannot avoid to run Process Builder. It will always run when record is saved.

If you really need switch like that you can for example add an underwater checkbox field to your Object which cannot be checked by users but you would check it in your test class and after then in your PB look for that checkbox to verify if PB should run.

Keep in mind that this is a workaround and it's not recommended by any best practices.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.