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 = 'magulancse24@gmail.com';
        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

Sharing is Caring!!! Share this with your friends!!!

submit to reddit