How to test static methods in Salesforce?

To test static methods in Salesforce, we have to call the method along with the controller name, not with the object of the controller.

Example:

Apex Class:

public class example
{
    public static integer add(integer a, integer b)
    {
        return (a+b);  
    }

    static testMethod void testforExample()
    {
        example.add(8,9);
    }
}

No comments:

Post a Comment