You need to sign in to do that
Don't have an account?
Need Help for Test Coverage Code
Hi,
I just finished the code below. It works fine as my expect but I have a hard time writing the test code. Can anyone please have a look at it and help me write the test code? Thanks in advance.
trigger UpdateUpcoming on Task (after insert, after update)
{
Set<id> AccountIDs = new set<id>();
list<Account> AcctList = new list<Account>();
for(task c : Trigger.new)
{
for(Account at:[Select id,upcoming_due__c From Account where id =: c.accountid])
{
if (date.valueof(c.ActivityDate) == null)
at.upcoming_due__c = null;
else
if (at.upcoming_due__c == null)
at.upcoming_due__c = date.valueof(c.ActivityDate);
if (date.valueof(c.ActivityDate) < at.upcoming_due__c)
at.upcoming_due__c = date.valueof(c.ActivityDate);
else
at.upcoming_due__c = at.upcoming_due__c;
AcctList.add(at);
}
}
update AcctList;
}
I am sorry, but ignore the line:
if (date.valueof(c.ActivityDate) == null)
at.upcoming_due__c = null;
else
Can you post the @isTest class you have.
Thanks for your reply, here is the test I have, but does handle the "IF" section.
@isTest
private class testUpdateUpcomingTest0
{
public static testMethod void unitTestinsert_Contact_Activity4Task()
{
account ac=new account(name='test');
insert ac;
case c=new case(status='abc',accountid=ac.id);
insert c;
}
}
You should create a task also.