Test Methods Must Be In Test Classes

Impact area

Performance

Severity

Medium

Affected element

Apex Class

Rule ID

SF-OVERRIDE-BOTH

Impact

Test methods marked as a testMethod or annotated with @IsTest, but not residing in a test class should be moved to a proper class or have the @IsTest annotation added to the class. Support for tests inside functional classes was removed in Spring-13 (API Version 27.0), making classes that violate this rule fail compile-time. 

Remediation

Create an apex class with @isTest annotation and move the method to the class.

Time to fix

30 min

References

This rule is linked to TestMethodsMustBeInTestClasses

What's here


Related content

Apex Page rules

Salesforce rules




Last modified on Oct 3, 2023