You need to sign in to do that
Don't have an account?
Sami Shakith
Test class for update trigger
Hi, I am new to salesforce. I dont know how to write a test class for update trigger. I need some one help. Just please give a simple example for test class to update a trigger.
Assuming you have a update trigger on Account, here is a sample example how you can cover the update part of trigger.
Test Method:
Sample Update Method:
static testMethod void UpdateAccount()
{
Account acc = new Account();
acc.Name = 'Test Update';
acc.Mobile = '12345';
insert acc;
acc.Country = 'India';
update acc;
}
Thanks,
Ram
All Answers
If you have trigger which is on update event, then in the test class you can actully create a sample record of that object and update that record so it will fire the trigger.
Here you go:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_qs_HelloWorld.htm
Thanks,
Pratik
Assuming you have a update trigger on Account, here is a sample example how you can cover the update part of trigger.
Test Method:
Sample Update Method:
static testMethod void UpdateAccount()
{
Account acc = new Account();
acc.Name = 'Test Update';
acc.Mobile = '12345';
insert acc;
acc.Country = 'India';
update acc;
}
Thanks,
Ram
Please mark this anwers as correct if its helpful.
Thanks,
Ram