You need to sign in to do that
Don't have an account?
Brandon Wermes
Lack of code coverage for Task Trigger
Hello,
I am working to build a trigger that updates an Opportunity when a Task is added to the opportunity. The trigger is successful in the Sandbox, however my Apex Class to test the trigger is presenting 0% code coverage. I am new to Apex and more of a "Desktop Admin" so any help would be appreciated.
The Trigger:
The Class:
I am working to build a trigger that updates an Opportunity when a Task is added to the opportunity. The trigger is successful in the Sandbox, however my Apex Class to test the trigger is presenting 0% code coverage. I am new to Apex and more of a "Desktop Admin" so any help would be appreciated.
The Trigger:
trigger OptyUpdateonTaskInsert on Task (after insert, after update) { List<Opportunity> lstOpty = new List<Opportunity>(); for(Task T : Trigger.New) { if(T.WhatId != null && string.valueof(T.WhatId).startsWith('006')) { Opportunity opt = new Opportunity(id=T.WhatId); lstOpty.add(opt); } } update lstOpty; }
The Class:
@isTest(seealldata=true) public class testTask{ private static testmethod void testTaskActivity(){ Opportunity o = new Opportunity( AccountId = '0015500000AByHM', Name = 'Test 2', StageName = 'Proposal Review', CloseDate = (System.now()).date(), Type = 'New System'); insert o; Task t = new Task( WhatId = o.Id, Subject = 'Sample Email', Priority = 'Normal', Status = 'Completed', OwnerId = UserInfo.getUserId()); insert t; } }
I recently had the same, code coverage in dev console was showing as 0%. If you check from the UI it shows as, hopefully, 100%. Go to settings, develop, apex test execution and it shows the actual coverage. In dev console it shows 0.
I was able to go ahead and deploy.
Must be a bug somewhere.
All Answers
I recently had the same, code coverage in dev console was showing as 0%. If you check from the UI it shows as, hopefully, 100%. Go to settings, develop, apex test execution and it shows the actual coverage. In dev console it shows 0.
I was able to go ahead and deploy.
Must be a bug somewhere.
I don't see that the Apex Class is making a Web Service call, so I'm at a loss.