You need to sign in to do that
Don't have an account?
Madevala Jithender
How do i write test class for a Trigger
trigger ClosedOpportunityTriigger on Opportunity (after insert,after update) {
list<task> tasklist = new list<Task>();
for(opportunity opp : Trigger.new){
if(opp.stagename == 'closed won'){
tasklist.add(new task(subject = 'follow up Test Task',whatid = opp.id));
}
}if(tasklist.size()>0){
insert tasklist;
}
}
list<task> tasklist = new list<Task>();
for(opportunity opp : Trigger.new){
if(opp.stagename == 'closed won'){
tasklist.add(new task(subject = 'follow up Test Task',whatid = opp.id));
}
}if(tasklist.size()>0){
insert tasklist;
}
}
Can you use the below test class which gives you 100% coverage by using all the best pratices in test class.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
Try Below Test Class 100% Coverage Please Mark It As Best Answer If It Helps
Thank You!
I see you are an active contributor on DF and appreciate all your valuable contribution. Offlate there have been a number of answers which are almost similar to mine which might not help end user.
Could you please refrain from posting similar content because in the end, it is only varied perspectives of solving problem that can add value to end users.
Same content is subject to deletion.
Thanks,