You need to sign in to do that
Don't have an account?
Hermann Ouré
Code Coverage error on Trigger despite showing 100%
Hello,
I have a code coverage of 100% for my trigger but uploading my packages to production I have an error
Code Coverage Failure
Your code coverage is 74%. You need at least 75% coverage to complete this deployment.
I really don't understand why when my code is covered 100%
my Trigger:
my Test class:
Thank you
I have a code coverage of 100% for my trigger but uploading my packages to production I have an error
Code Coverage Failure
Your code coverage is 74%. You need at least 75% coverage to complete this deployment.
I really don't understand why when my code is covered 100%
my Trigger:
trigger CaseConcernAircallDateTrigger on Task (after insert) { List<Case> cList = new List<Case>(); for(Task t: Trigger.New) { if(t.WhatId!=Null && t.whatId.getsObjectType() == Case.sObjectType){ Case c = new Case(); c.Id = t.whatId; c.Last_Aircall_Logged__c = t.CreatedDate; cList.add(c); } } if(cList.size() > 0) update cList; }
my Test class:
@isTest public class CaseConcernAircallDateTriggerTest { @isTest static void testAircallDateUpdate() { Contact con = new Contact (FirstName = 'First Name',LastName = 'Test'); insert con; Case c = new Case(Status = 'New',ContactId = con.Id,Phone_Number__c = '123456789'); insert c; Task t = new Task(Subject = 'Test', WhatId = c.Id); insert t; c.Id = t.WhatId; c.Last_Aircall_Logged__c = t.CreatedDate; update c; } }
Thank you
All Answers
Greetings!
There might be an another test class which is also covering the code for your trigger.So,I would suggest you to check the list of test classes which are covering for the trigger and make sure you add the test classes while deploying the trigger to the production.
You can check the list of the test classes by clicking on the down arrow symbol as shown below:
Once,you click on the down arrow then you will get to know which test class covered the trigger with the percentage.So,it will be easy to deploy the trigger code as well.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
i found in your code, you are not insert case but only update dirctly case list. So first you need to insert case.
If this solution is usefull for you, Please mark as a Best Answer to help others.
Regards
Mukesh
Hello Shirisha,
Thanks for your reply.
I just checked but it seems that there is only 1 class and it looks covered at 100%
Hello Mukesh,
I am a complete Novice,
At what Line should I add insert case?
I have made a few tries without success.
Thanks
Insted of update you need to use
if(cList.size() > 0) insert cList;
If this solution is usefull for you, Please mark as a Best Answer to help others.
Regards
Mukesh