June 26, 2013

Test Class for Static Method in Apex in Salesforce

Sample Test Class:

private class testClass
    static testMethod void test()
        Member__c m = new Member__c();
        m.Name = 'Sample';
        m.Email_Address__c = '
Your email address';
        m.Age__c = 25;
        insert m;

here memberApproval is an Apex class and callApproval is a static method.

To call a static method in a test class, we have to use class name instead of object of that class.


No comments:

Post a Comment