8

I am experiencing something weird on the Sandbox with all the test classes. whenever I run a test class I get the error: Method does not exist or incorrect signature: Test.startTest(). I am completely unfamiliar with this error and i don't know what happened because all these test classes are working just fine in production and where working just fine on Sandbox 2 days ago

I will appreciate any help!

Test class structure i am using:

@istest
private class ClonePlus_Test {

 static testmethod void testcloneplus () {
   ......

   Test.startTest();
   system.runAs(user){

     ......
   }
   Test.stopTest();

  }
}

3 Answers 3

44

There is a good chance you actually created a class somewhere called Test. Find it and delete it.

9
  • 5
    You can't just nilly-willy delete a class, in case it's used somewhere. Careful analysis is important before you just go about deleting a class. I'd suggest renaming it, and try compiling to see what broke.
    – sfdcfox
    Commented Sep 4, 2014 at 20:16
  • dphil, this is affecting all the test classes. all my test class start with test_'ClaseName'. This is weird because the were working just fine 2 days ago
    – Carlos
    Commented Sep 4, 2014 at 21:04
  • Do you have any classes that is actually called Test?
    – dphil
    Commented Sep 4, 2014 at 21:07
  • i found it.. you guys where correct, i spent so many hours trying to find the issue. Thank you so much
    – Carlos
    Commented Sep 4, 2014 at 21:09
  • 1
    Just had the same problem a couple of days ago. Pain in the bum. There should be a set of reserved words and the platform shouldn't allow you to create classes with those names. Commented Sep 5, 2014 at 9:34
11

Even though the other answers are correct, you can resolve the issue also by explicitly using the System namespace like this

System.Test.startTest();
System.Test.stopTest();

That will use the System Test class instead of your own Test class and prevent any clashes between the two.

This is useful when you cannot delete the existing Test class for good reason.

1
  • This would solve OPs problem. The main issue I have with this is that it will likely recreate the problem in the future when either the OP forgets about it or a new dev works in the org, but it is still information that is useful to know.
    – dphil
    Commented Sep 19, 2016 at 14:09
8

The most common cause I've seen when I get an unexplained method does not exist for a salesforce supplied class method, is that I or someone else created a class with the same name as the standard one.

Since Test would be a common name for a class someone created just to test something etc. I would try checking your org for that, and if it exists renaming it and trying again.

--KC

2
  • But this is affecting all the test classes. all my test class start with test_'ClaseName'
    – Carlos
    Commented Sep 4, 2014 at 21:02
  • i found it.. you guys where correct, i spent so many hours trying to find the issue. Thank you so much
    – Carlos
    Commented Sep 4, 2014 at 21:10

You must log in to answer this question.

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