2

I searched the related documents but didn't find any specific requirement for the testmethod to be static. But from my previous experience, they are always static, and that is logical. But is it a must thing for a testmethod to be static?

2 Answers 2

1

According to my knowledge they have to be static.

To define an Apex method as a 'test method', simply define the method as static and add the keyword testMethod. 
1
  • I agree with Artur. Although you are right, I cannot find anywhere it explicitly says that it HAS to be static, but it's my understanding that is the case, just cant find it documented. May 16, 2014 at 13:11
1

Yes, it must be defined as static. If you try to save a test class without a static test method, you get an error:

Only static top-level class methods can be test methods 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .