Reputation: 415
Hello Folks, I am really new to Apex Development and currently trying to write a test case for this trigger. Any kinds of help is really appreciated!
trigger Milestone1_Expense_Trigger on Milestone1_Expense__c (before insert, before update)
{
if(Trigger.isBefore)
{
Milestone1_Expense_Trigger_Utility.handleExpenseBeforeTrigger(Trigger.new);
}
}
Thanks in Advance!
Upvotes: 0
Views: 6484
Reputation: 11330
Take a look at the link matthew provided. That should give you an idea on what needs to be done and how you assert and confirm if what you are trying to do is actually happening. If i were to explain it in a simple way.
Your trigger would get fired when an record is inserted/updated in Milestone1_Expense__c. So in your test class all you need to do create a test data for Milestone1_Expense__c and give an insert statement.
if i were to give an example for Account
Account a = new Account(Name = 'test', Company__c = 'test');
insert a;
instead of Account here you can give use your custom object and use the fields in that custom object
Upvotes: 1
Reputation: 7337
Check out this introduction to Apex Code Test Methods, and look for the code block that has the http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
. That code section is an example of testing an Apex Trigger.
Upvotes: 2