You need to sign in to do that
Don't have an account?
Need to write a Test Coverage Code
Hi,
I just wrote down the code below but have a hard time writing test coverage code. Can someone please write it or give me some ideas pointing me to the right direction. Thanks very much.
Trigger UpdateUpcoming on Task (after insert, after update)
{
Set<id> AccountsIDs = new Set<id>();
List<Account>AcctList = new List<Account>();
For (task t:Trigger.new)
{
For (account at:[select id,upcoming_due__c,(select id,activitydate from tasks where isclosed = false and activitydate != null order by activitydate asc limit 1) from account where id =: t.accountid])
{
If (date.valueof(t.activitydate) < at.upcoming_due__c || at.upcoming_due__c == null)
at.upcoming_due__c = date.valueof(t.activitydate);
If (trigger.isDelete)
at.upcoming_due__c = null;
AcctList.add(at);
}
}
update AcctList;
}
Use below it will work
@isTest
private class testaccount
{
private static TestMethod void testTrigger()
{
account a=new account(lastname='aa');
insert a;
task t=new task(activitydate=system.today(),whatid=a.id);
insert t;
update a;
}
All Answers
Hi,
i have write the sample code for your trigger. try this code
@isTest
private class testaccount
{
private static TestMethod void testTrigger()
{
account a=new account(lastname='aa');
insert a;
task t=new task(activitydate=system.today(),whatid=a.id)
insert t;
update a;
}
}
Thanks
Hi nagalakshmi, thanks so much for you reply. I tried it but got this error:
Error: Compile Error: unexpected token: 'insert' at line 9 column 0
Which is the Insert t..
can you please advise?
Use below it will work
@isTest
private class testaccount
{
private static TestMethod void testTrigger()
{
account a=new account(lastname='aa');
insert a;
task t=new task(activitydate=system.today(),whatid=a.id);
insert t;
update a;
}