+ Start a Discussion
Ram Srivastav 7Ram Srivastav 7 

Code coverage


I have defined apex trigger code which is working fine but the issue is with code coverage, its showing only 73% while deploying it into the production. Please help

Code snippet: 

trigger sendEmail on Case (after insert,after update) {
   Public static Boolean InitialEmail =false;
   Public static Boolean FinalEmail =false;
    //adding for check of trigger behaviour
     for(Case c:trigger.new) {
        if ((trigger.isInsert || (trigger.oldMap.get(c.Id).Send_Email_to_Contact__c != c.Send_Email_to_Contact__c)) && (c.Send_Email_to_Contact__c && !c.Do_not_Send_Email__c  && c.Email_of_Complainant__c!=null && c.Status!='Completed')) {
              sendEmailMessage(c.id,c.ownerId,c.Internal_Comments__c,c.Email_of_Complainant__c,c.Site_Details__c,c.CaseNumber,c.Case_Customer_Reference__c );
        if ((trigger.isInsert || (trigger.oldMap.get(c.Id).Status != c.Status)) && (c.Final_email_to_contact__c && !c.Do_not_Send_Email__c  && c.Email_of_Complainant__c!=null && c.Status=='Completed')) {
Trigger require 1% of coverage only. Check your organisation main classes. Apex classes must have 75% overall coverage.
Ram Srivastav 7Ram Srivastav 7
Hello Batman,

Apex class checkRecursive() is covered with 1000 % code coverage. issue is while deploying the apex trigger its throwing an error that code coverage is only 73 % while it should be 75 % for deployment in production.
Could anyone help me to get it out.....
David "w00t!" LiuDavid "w00t!" Liu
Do you have another trigger using checkRecursive? It's possible that the other trigger is "consuming" the single run, then this trigger which runs afterward doesn't run as a result of this!
Ram Srivastav 7Ram Srivastav 7
Hi David,

In the above triggers, I have one apex class as well checkRecursive() which already covers 100 % code coverage. But still i am unable to deploy the change into salesforce production.
Please help...