You need to sign in to do that
Don't have an account?
ashu 6112
test class_help
I have this trigger, need to write test class for this:
Please help.
trigger AccountInitiationDate on Account (before insert) {
List<Account> lstacc = new List<Account>();
for(Account account : trigger.new){
//if(account.Initiation_Date__c==null){
account.Initiation_Date__c=System.today();
account.Approval_Date__c=null;
account.Status__c='Draft';
lstacc.add(account);
System.debug('AccountInitiationDate Initiated ');
//}
}
}
Please help.
trigger AccountInitiationDate on Account (before insert) {
List<Account> lstacc = new List<Account>();
for(Account account : trigger.new){
//if(account.Initiation_Date__c==null){
account.Initiation_Date__c=System.today();
account.Approval_Date__c=null;
account.Status__c='Draft';
lstacc.add(account);
System.debug('AccountInitiationDate Initiated ');
//}
}
}
https://developer.salesforce.com/page/How_To_Test_Your_Apex_Triggers
https://trailhead.salesforce.com/modules/apex_testing/units/apex_testing_intro
There are also plenty of existing posts on here about writing test classes.
1) http://amitsalesforce.blogspot.com/search/label/Test%20Class
2) http://amitsalesforce.blogspot.com/2015/06/best-practice-for-test-classes-sample.html
3) https://developer.salesforce.com/page/How_To_Test_Your_Apex_Triggers
Trailhead is best way to learn
1) https://trailhead.salesforce.com/modules/apex_testing/units/apex_testing_intro
To Create the test class for Trigger you need to follow below step
1) Create Test Data in your case you need to create Account data
Like below Let us know if this will help you