Loading
Scalability
ApexGuru Test Case Antipattern: Using the testMethod Keyword

ApexGuru Test Case Antipattern: Using the testMethod Keyword

The testMethod syntax is outdated. Avoid using it to preserve confidence in your test suite and deployment quality.

Scope

Detection and recommendation

Detection Example

public class MyTestClass {
   static testMethod void myTest() {
      System.debug('This test will be versioned out soon as it has testMethod keyword');
   }
}

Recommendation

Always annotate test classes with @isTest. Avoid legacy syntax. Adopt modern standards that properly recognize and execute all test methods.

@isTest
private class MyTestClass {
   @isTest
   static void myTest() {
      System.debug('This test follows Salesforce recommended practices');
   }
}
 
Laddar
Salesforce Help | Article