You'd write it the same as any other test class. Set up the required data, execute the method and then verify the results. The invocable aspect is just an annotation that makes it available to particular areas of the Salesforce platform, you can still call it directly.
You'd write it the same as any other test class. Set up the required data, execute the method and then verify the results. The invocable aspect is just an annotation that makes it available to particular areas of the Salesforce platform, you can still call it directly.
Bob , I am facing a similar 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?
Bob - I know you don't prefer giving out exact code in your recommendations, but here is my code. I find it easier to explain my situation through code here. Please help.
///////////////////////Process flow fires here, checkbox changes from False to True////////////////////////////////// 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];
All Answers
Bob ,
I am facing a similar 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?
Regards
Shrey Tyagi
Thanks!!!
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;
///////////////////////Process flow fires here, checkbox changes from False to True//////////////////////////////////
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;
}
}