Why Test methods are always static?
Test Methods are static 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 excecutes.
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.
Comments
Post a Comment