+ Start a Discussion
Martin Wheeler MARLAMartin Wheeler MARLA 

please help achieving 75%, i am tired of trial and test

trigger immediate_response on pba__Listing__c (before delete,after insert,before update) {
 
    String api_status = 'trigger' ;
    String url = 'https://fine-residential.com/app_sf/sf_endpt.php';

    String body;

  if(trigger.isDelete ){
 
  api_status = 'DELETED'; 
       
 for (pba__Listing__c acc : Trigger.old) {
              
              body = 'id='+acc.Id+'&method='+api_status+'&inbound_initiative_id=1';

              HTTPRequestSender.sendHTTPRequest(url, body);
       }       
 
      
  }else{   
      
//if((trigger.isInsert || trigger.isUpdate) ){
        if(trigger.isBefore && trigger.isUpdate){
         
         api_status = 'UPDATE';
         
        }
         
        if(trigger.isInsert ){
         
         api_status = 'INSERT';
         
        }
            
         
         for (pba__Listing__c acc : Trigger.new) {
                      
                      body = 'id='+acc.Id+'&method='+api_status+'&inbound_initiative_id=1';
        
                      HTTPRequestSender.sendHTTPRequest(url, body);
                      
                      
                  if(acc.api_modified_date__c  !=acc.api_modified_date_2__c )
                   acc.api_modified_date__c   = acc.lastModifiedDate;
                   else
                   acc.api_modified_date_2__c   = acc.lastModifiedDate;
                                     
                                     
                                     
                                     
               }       
  }//end of else if not isdeleted
 
 }
pconpcon
It would be nice if you included some of you "trial and error"  You will not really find people that are willing to write test code for you for free.  If you were to include some of your tests that you've written then we can help direct you in the correct way to generate meaningful tests that cover this.  In the meantime, I suggest that you read over this article (https://blog.deadlypenguin.com/testing/strategies/) that covers test planning and would help you understand how to structure your tests in a way to generate meaningful tests to increase your test coverage

NOTE: Please use the "Add a Code Sample" button (icon <>) when adding code to make it easier to read and reference.