You need to sign in to do that
Don't have an account?
Brandon Wermes
Lack of Code Coverage on 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:
Thank you very much for assistance.
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; } }
Thank you very much for assistance.