Test Class for Static Method in Apex in Salesforce

Sample Test Class:

@isTest
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;
        memberApproval.callApproval(m.Id);
    }
}


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.

Cheers!!!

No comments:

Post a Comment