You need to sign in to do that
Don't have an account?
How to write test class for below trigger?
Hi All,
I have just started writing triggers but don't know how to write test class for code coverage,Below is the Trigger code.IF any help on this is highly appreciated. The scenario is I have created the WF Task on Lead object so that whenever the Leads get qualified the Task get created but unfortunately the field which we would like to update on Task i.e Type is not available while creating Task,So i was force to write the trigger for it ,but don't know how to write test class for it.
trigger TypeUpdateonWFTask on Task (before insert)
{
for (Task TP:Trigger.new)
{ if (TP.Subject.contains('Qualified') && TP.Type == null)
{ TP.Type = 'Qualified';
}
} }
Hi Mear,
Here is your trigger's test class whose codecoverage is 100%.
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thanks,
Hitesh Patel
SFDC Certified Developer & Administrator
All Answers
Hi Mear,
Here is your trigger's test class whose codecoverage is 100%.
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thanks,
Hitesh Patel
SFDC Certified Developer & Administrator
Hi Hitesh,
Thanks for your reply,I really appreciate your helping hand.
Could you please navigate me towards how to test the trigger.I don't know the path :-(
Regards,
Subbu
Hi,
To Navigate towards test the trigger follow the process.
1. open Apex class(Test class) which you have written.
go to setup -> App Setup -> Develope -> Apex Classes
2. Find your Test class and click on className link.
3. There is a button above "Run Test" click on that
4. Now click on "Developer Console" button
5. There is a section "Overall Code coverage" at right side
6 Find your trigger there and see percentage.
Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thanks,
Hitesh Patel
SFDC Certified Developer & Administrator
Thanks Hitesh,
That was helpful,Community sustains untill people like you are there :-)
Regards,
Subbu.