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.
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.
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;
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.