You need to sign in to do that
Don't have an account?
Rahul
Hi friends, can some one help me with this test class
I had 100% code coverage yesterday but today its 69% only. I dont know how this happened.
This is the code:-
trigger updatestatus on Task (after insert) {
set<id> setid = new set<id>();
list<contact> lstcon = new list<contact>();
for(task t :trigger.new){
setid.add(t.whatid);
setid.add(t.whoid);
}
for(contact cc :[select id,boolean__C,(select subject from tasks ) from contact where id=:setid]){
For(task t1 :trigger.new){
if(t1.subject=='Mass Email: Fourth Followup for Accounts New'){
Contact cc1 = new contact();
cc1.id=cc.id;
cc1.boolean__c='True';
lstcon.add(cc1);
}
update lstcon;
}
}
}
This is the Test class :-
@isTest
private class SampleTestClass {
static testMethod void validateContactsAndTasks() {
Contact con = new Contact(LastName='Sample Last NAme', boolean__c=True);
insert con;
Task tsk = New Task();
tsk.WhoId = con.Id;
tsk.Subject = 'Mass Email';
tsk.Status = 'In Progress';
tsk.Priority = 'Low';
insert tsk;
}
}
Please help
This is the code:-
trigger updatestatus on Task (after insert) {
set<id> setid = new set<id>();
list<contact> lstcon = new list<contact>();
for(task t :trigger.new){
setid.add(t.whatid);
setid.add(t.whoid);
}
for(contact cc :[select id,boolean__C,(select subject from tasks ) from contact where id=:setid]){
For(task t1 :trigger.new){
if(t1.subject=='Mass Email: Fourth Followup for Accounts New'){
Contact cc1 = new contact();
cc1.id=cc.id;
cc1.boolean__c='True';
lstcon.add(cc1);
}
update lstcon;
}
}
}
This is the Test class :-
@isTest
private class SampleTestClass {
static testMethod void validateContactsAndTasks() {
Contact con = new Contact(LastName='Sample Last NAme', boolean__c=True);
insert con;
Task tsk = New Task();
tsk.WhoId = con.Id;
tsk.Subject = 'Mass Email';
tsk.Status = 'In Progress';
tsk.Priority = 'Low';
insert tsk;
}
}
Please help
I would try updating your test tsk.Subject to equal "Mass Email: Fourth Followup for Accounts New"
All Answers
I would try updating your test tsk.Subject to equal "Mass Email: Fourth Followup for Accounts New"