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?

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 '14 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 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.