10

Is someone getting the error "Test methods must be in test classes"

I am using @Istest annotation inside the class:

public class someclass{
    @istest
    public static void testme(){
    ...
    }
}

When I switch it to version 27 it works fine. Is this a documented expected behavior related to spring 13.Are test classes now enforced to be written in a separate test class than writing at the end of the main class?

  • From summer 13 all test methods must be in separate test class . – Mohith Shrivastava Jun 6 '13 at 5:43
  • 3
    It's actually a good thing. The "storage usage" calculation used to lie (maybe they fixed it). It was counting the testmethods inside normal classes against your total limit of Apex code characters even though thee description claimed to be otherwise ;) So forcing to push to separate classes keeps your usage down too. – eyescream Jun 6 '13 at 6:36
  • yes u r right :) – swatkat Jun 6 '13 at 7:24
14

Found this in Summer'13 release notes :

Starting in Summer ‘13, test methods can be defined only in test classes (classes annotated with @isTest). You can no longer add a test method in a non-test class. This change applies to new Apex code saved using Salesforce.com API version 28.0 and later. Apex code saved using earlier API versions isn’t affected.

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.