function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com 

Test Class for Invocable Apex

Hi All,
    I am facing a known issue. As per salesforce documentation "Process Flows are deactivated upon deployment". Now I have a scenario where a checkbox toggles from False to True in parent record , process flow fires and invokes an apex class, that class creates a child record related to that parent. Now at the time of deployment my process flow is deactivated , so when I query the child records in my test class I get the error "List has no rows for assignment". 
Now to compensate for the inactive flow how can I imitate the exact firing logic in my apex test class?

Test Class sample is given below:

@isTest
public class Test_PrasApexCode {
    
    static testMethod void testDoGet1() {
        
        
        
        Costpoint_Project__c testCostpointProject = new Costpoint_Project__c();
        testCostpointProject.Business_Unit__c='SSES';
        testCostpointProject.Unit__c='EHS';
        testCostpointProject.Division__c='Environment';
        testCostpointProject.Review_Required__c=False;
        testCostpointProject.Project_Manager__c=u1[0].Id;
        insert testCostpointProject;
        
        
       
        
        
        Awarded_Project__c ap= new Awarded_Project__c();
        ap.Opportunity__c=testOpp.Id;
        ap.Project__c=testCostpointProject.Id;
        insert ap;
        

       ///////////////////////Process flow fires here//////////////////////////////////
        testCostpointProject.Review_Required__c=True;
        update testCostpointProject;

///////////////////////////////////////////////////////////////////////////////////////////////////
        

        
        
        //Fetch related Project Risk Review form.
       //This is where the error is thrown
        Project_Risk_Review__c ProRiskRev=[Select id,DVP__c,Project_Manager__c,Chair_Reviewer__c,Delegate__c 
                                           from Project_Risk_Review__c where Costpoint_Project__c=:testCostpointProject.Id Limit 1];

        
        ProRiskRev.Chair_Reviewer__c=u1[0].Id;
        ProRiskRev.DVP__c=u1[1].Id;
        Update ProRiskRev;


        

    
    }
    

}