You need to sign in to do that
Don't have an account?
Jacob Elliott 8
Create Test Class For Approval Process Trigger
Hello, I am trying to unlock a "Matter" record when the record goes into an approval process. A trigger will see that it is locked and then unlock the record. This is working, but my test class is only covering 66%. How can I get it to 100%? Thanks!
Trigger
Test Class
Trigger
trigger UnlockMatter on litify_pm__Matter__c (after insert, after update) { for(litify_pm__Matter__c matter : trigger.New) { If(Approval.isLocked(matter.Id)) { Approval.unlock(matter.Id); } } }
Test Class
@isTest public class TestUnlockMatter { @isTest static void TestEditMatterInApproval() { // Test data setup // Create A Party to assign to the matter Account party = new Account(litify_pm__First_Name__c='Jim', litify_pm__Last_Name__c='Halpert'); insert party; // Create A Matter that is locked and unlock and edit it litify_pm__Matter__c matter = new litify_pm__Matter__c(litify_pm__Display_Name__c='Jim Halpert vs. Dwight Schrute', litify_pm__Client__c= party.Id); insert matter; Approval.lock(matter.Id); //Perform Test Test.startTest(); Approval.unlock(matter.Id); matter.litify_pm__Display_Name__c ='Jim Halpert vs. Micheal Scott'; Test.stopTest(); } }
Hope that your day is off to an amazing start. Can we request for you to try the new updated test class below and report how it works for you? Thank you, and hope this helps. May God bless you abundantly.
Best Regards,
Anthony McDougald
All Answers
Hope that your day is off to an amazing start. Can we request for you to try the new updated test class below and report how it works for you? Thank you, and hope this helps. May God bless you abundantly.
Best Regards,
Anthony McDougald