This question is an exact duplicate of:

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

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

marked as duplicate by Derek F, Pranay Jaiswal, glls, Vijay Ganji, battery.cord Jun 10 at 13:15

This question was marked as an exact duplicate of an existing question.


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

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

static void testClassforExample(){

  List<Case> lsttestcases = [SELECT Id,CaseNumber FROM Case];
   ExampleClass.publishCaseUpdateNotifications(lsttestcases );
 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= '' ));
   ExampleClass.publishCaseUpdateNotifications(invalidcaselst );


Not the answer you're looking for? Browse other questions tagged or ask your own question.