+ Start a Discussion
Himanshu Jasuja 9Himanshu Jasuja 9 

Process Builder condition not fulfilling in Test Class

There is a lookup of opportunity on custom object 'Job Order' and I have process builder on job order as below:-

I choose Criteria for updating records [![enter image description here][1]][1]- No criteria—just update the records

joborder.Public_Description__c   formula   opportunity.Description.

When i insert job order in test class following error occurs 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_EXECUTE_FLOW_TRIGGER, The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30140000000TTVx. Contact your administrator for help.


I know this error coming from process builder because i am not able to satisfy process builder conditions in my test class

Here is my test class code and process builder screenshot.

@isTest
  Public class test_updatePrimaryRecuriter{
        static testMethod void validate(){
        
          Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
          User u = new User(Alias = 'standt', Email='testporder@testorg.com', 
          EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
          LocaleSidKey='en_US', ProfileId = p.Id, 
          TimeZoneSidKey='America/Los_Angeles', UserName='testporder1@testorg.com');

          System.runAs(u){
         // The following code runs as user 'u' 
          System.debug('Current User: ' + UserInfo.getUserName());
          System.debug('Current Profile: ' + UserInfo.getProfileId()); 
        }  
           Account acc = new Account();
           acc.Name = 'Test';
           insert acc;
           
           Opportunity op = new Opportunity();
           op.name = 'Test opportunity';
           op.StageName = 'Closed Lost';
           op.CloseDate = System.Today();
           op.Opportunity_Source__c = 'Conference';
           op.AccountId = acc.Id;
           op.Public_Description__c = 'test';
           op.Public_SkillSet__c='test';
           op.Description='test';
           insert op;
           system.debug('-----------------op'+op.Id);
           ts2__Job__c jobOrder = new ts2__Job__c();
           jobOrder.Name = 'Test';
           JobOrder.ts2__Status__c='Lost';
           jobOrder.ts2__Account__c = acc.Id;
           jobOrder.ts2__Recruiter__c = u.Id;
           
           jobOrder.Opportunity__c = op.Id;
           jobOrder.Public_Description__c = '';
           jobOrder.Public_SkillSet__c='';
           jobOrder.ts2__Job_Description__c='';
           jobOrder.OwnerId = u.Id;
           
           insert jobOrder;
          
        }
}

User-added image