-2
    for (Database.SaveResult result : results) {
    if (!result.isSuccess()) {
        for (Database.Error error : result.getErrors()) {
            System.debug('Error returned: ' +
                error.getStatusCode() +' - '+
                error.getMessage());
        }

And Do need to write test class for below trigger?

 trigger Cases on Case (after insert) {
   if(Trigger.isAfter) {
    // Send the list of cases (Trigger.new) to the example function
    ExampleClass.publishCaseUpdateNotifications(Trigger.new);
  }
}
0

1 Answer 1

0

you should pass invalid values for PF event via case. please try below code and let me know if you get any issue .

 @isTest
   public class ExampleTestClass {
  @testSetup static void setup(){
       Case testcase = new Case(Subject ='Test');
       insert testcase;
}

@isTest
static void testClassforExample(){

  List<Case> lsttestcases = [SELECT Id,CaseNumber FROM Case];
   Test.startTest();
   ExampleClass.publishCaseUpdateNotifications(lsttestcases );
   Test.stopTest();
 List<Case_Updated__c> casUp = [Select Id From Case_Updated__c];
  System.assertEquals(1, ExampleClass.notifications.size());
   List<Case> invalidcaselst = List<Case>();
   invalidcaselst.add(new Case(Subject ='Test', Id= '' ));
   Test.startTest();
   ExampleClass.publishCaseUpdateNotifications(invalidcaselst );
   Test.stopTest();
  }  

}

Not the answer you're looking for? Browse other questions tagged .