Activity Forums Salesforce® Discussions Why test method always static in Salesforce?

  • Adarsh

    Member
    February 7, 2018 at 6:01 am

    Hi Uday,

    Test Methods are static in Salesforce because you do not call the test methods explicitly when you run a class for execution.

    When you run your apex tests these methods needs to be executed whether they are called or not which is why we make them static so they can be run while the class executes.

    A static method doesn’t require an instance of the class in order to run. They’re created with every object instantiated from the class in which they’re declared.

    Hope it helps 🙂

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos