5

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();

  }
}
23

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

|improve this answer|||||
  • 4
    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 Sep 4 '14 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 Sep 4 '14 at 21:04
  • Do you have any classes that is actually called Test? – dphil Sep 4 '14 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 Sep 4 '14 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. – Boris Bachovski Sep 5 '14 at 9:34
8

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.

|improve this answer|||||
  • 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 Sep 19 '16 at 14:09
7

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

|improve this answer|||||
  • But this is affecting all the test classes. all my test class start with test_'ClaseName' – Carlos Sep 4 '14 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 Sep 4 '14 at 21:10

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.