You need to sign in to do that
Don't have an account?
Shaun B.
Need code coverage
Hi there!
I am new to Apex, but would like to deploy the following Apex code to my org. The issue however is that I don't know how to write unit tests. Can anyone assist?
I am new to Apex, but would like to deploy the following Apex code to my org. The issue however is that I don't know how to write unit tests. Can anyone assist?
trigger UpdateCaseCommentFields on FeedItem (after insert) { List<Case> updates = new List<Case>(); for (FeedItem fi : Trigger.new) { if (fi.ParentId.getSObjectType() == Case.SObjectType && fi.Visibility == 'InternalUsers') { updates.add(new Case( Id = fi.ParentId, Last_Internal_Comment__c = fi.Body )); } else if (fi.ParentId.getSObjectType() == Case.SObjectType && fi.Visibility != 'InternalUsers') { updates.add(new Case( Id = fi.ParentId, Last_External_Comment__c = fi.Body )); } } update updates; }
First need to put a validation in your code to check the size of list updates list.
And Need to write test class for +ive and -ive cases.
-Thanks
Ashlekh Gera
All Answers
First need to put a validation in your code to check the size of list updates list.
And Need to write test class for +ive and -ive cases.
-Thanks
Ashlekh Gera