You need to sign in to do that
Don't have an account?
Created trigger - stuck on creating APEX test class
I created two very simple triggers and tested them in a sandbox. I'm not a developer, but put them together using suggestions from this board. Trigger 1: When a new contact is added to the Alumni Outreach object through a lookup to the Contact record, a checkbox (Alumni_Outreach_Project__c) on the Contact record is checked. Trigger 2: Unchecks the checkbox when a contact's record is deleted from the Alumni Outreach object. I tried to deploy them to Production using change sets and learned that I need to create an APEX test class.
Would anyone be able to help me get started with creating the test class? I'm not sure I'll be able to code this - do I need to create one class for each trigger?
Any help would be appreciated. Thanks
Trigger 1:
trigger AlumniOutreach_Check_Checkbox on Alumni_Outreach__c (after insert) {
List<Contact> updatedContacts = new List<Contact>();
Set<Id> ContactId = new Set<Id>();
for (Alumni_Outreach__c w : trigger.new)(
ContactID.add(w.Name_of_Alum__c));
for (Contact a : [SELECT id, Alumni_Outreach_Project__c FROM Contact WHERE id IN :ContactID]){
a.Alumni_Outreach_Project__c = true;
updatedContacts.add(a);
}
update updatedContacts;
}
Trigger 2:
trigger AlumniOutreach_UNCheck_Checkbox on Alumni_Outreach__c (after delete) {
List<Contact> updatedContacts = new List<Contact>();
Set<Id> ContactId = new Set<Id>();
for (Alumni_Outreach__c w : trigger.old)(
ContactID.add(w.Name_of_Alum__c));
for (Contact a : [SELECT id, Alumni_Outreach_Project__c FROM Contact WHERE id IN :ContactID]){
a.Alumni_Outreach_Project__c = false;
updatedContacts.add(a);
}
update updatedContacts;
Check out the following resource which should help:
http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods
Can I define the Contact Record type another way?
Thanks