You need to sign in to do that
Don't have an account?
Average test coverage across all Apex Classes and Triggers is 72
hi,
i have created one Apex Trigger under Task section, that is working fine in sandbox account. when i am trying to deploy the same Trigger in to production, i am getting "Average test coverage across all Apex Classes and Triggers is 72%, at least 75% test coverage is required". i am using Eclipse for deployment.
my Requirement is upon clicking save buttion on new Task page, i need to fire an trigger to get last completed task comments to merge with the current comments.
Here is the my Trigger:
trigger Update_Comments_Task on Task (before insert) {
List<Id> whoIds = new List<Id>();
for(Task oTask : Trigger.new){
whoIds.add(oTask.WhoId);
}
//Get Existing Tasks
List<Task> exTask =[select Id,Description from Task where WhoId in :whoIds and status = 'Completed' Order by CreatedDate Desc];for(Task oTask : Trigger.new){
if(exTask.Size() > 0){
for(Task tmpTask:exTask){if(oTask.Description!=null && tmpTask.Description!=null){oTask.Description = tmpTask.Description +
'\n' + oTask.Description;}
else if(oTask.Description==null && tmpTask.Description!=null){oTask.Description = tmpTask.Description;
}
else if(oTask.Description!=null && tmpTask.Description==null){oTask.Description = oTask.Description;
}
else{oTask.Description = '';}
break;}
}
}
}
the above Trigger is working fine in sandbox account.
Can you please help me, how can i improve my test coverage percentage to 75%.
Thanks you for your reply. i am very new to the Apex development.
can you please help on this how can i write test coverage in apex class.
Create a new Apex Class and a test method inside this class -
e.g.
public class TaskTrigger { public TestMethod void testTaskTrigger() { Task t = new Task(); insert t; } }
Then inside the test method write code that will run your trigger. Have a look at the Apex Documentation for more info - Link
hi
Thank you for your consistant help.
i have created apex class as you suggested and included same Task t=new Task(); insert t; inside the TestMethod.
then save the apex class. after that i clicked the "Run all Tests" button and getting test coverage 66% for my Trigger.
can you please help me on this.
I have problem regarding Package deployment in sales-force :( Its very strange that I have just 4 triggers and have not any single Apex Class so what I have to do for deployment I need TEST Methods for my Triggers. I created test methods for my all four triggers when I am going to upload option of package I am getting following ERROR :(
Thats very strange because I have not Apex class even that I am getting this problem please help me in this problem :(
My Triggers are mentioned below:
Trigger 1:
Trigger 2:
Trigger 3:
Trigger 4:
Please help me in this
Thanks,
Asif Khan
Now I created these test Cases against above mentioned Triggers :(
But on uploading of package I am getting this error
Average test coverage across all Apex Classes and Triggers is 1%, at least 75% test coverage is required
Please help me in this
Thanks,
Asif Khan
Hi I am trying to deploy one apex code in production from sanbox,in sanbox it showing as 88% coverage in production I am getting fallowing error.
Average test coverage across all Apex Classes and Triggers is 68%, at least 75% test coverage is required.
But not telling me which class is not covering can some please help me solving this issue
Kalluru i am having the same issue.
I have over 80% code coverage when i run all tests in both the sandbox and in produciton.
My new triggers both have coverage over 75% each but when i deploy it i get an error that i have only 69% test coverage.
Did you find a solution on this?