function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jamz_2010Jamz_2010 

Test Method Error

Hi,

 

I am just trying to write a test method for my class and I am getting the error:

 

 

Method does not exist or incorrect signature: Test.StartTest()

 

Does anyone know what might cause this? I have tried this in a blank class to ensure its not caused by any other code but I still get the same error.

 

Cheers

 

James 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

You don't happen to have a method or variable called Test that is overriding the system method do you?

Could you post the full method?

All Answers

JimRaeJimRae

Are you defining the method as a test method?

 

 

This works fine for me:

 

 

/** * This class is a sample test method */ @isTest private class testme { static testMethod void reallytestme() { system.debug('\n\nI am outside the test area'); Test.startTest(); system.debug('\n\nI am in the test area'); Test.stopTest(); } }

 

 

 

 

Jamz_2010Jamz_2010

Yes the method is the defined as a test method, the problem has only occurred since the Winter '10 upgrade. Strangely, if I don't use Test.StartTest() and Test.StopTest() the test method seems fine and achieves the code coverage...

 

Thanks for your help, I wonder what's going on?

 

James 

JimRaeJimRae

You don't happen to have a method or variable called Test that is overriding the system method do you?

Could you post the full method?

This was selected as the best answer
luckymeluckyme
You probably have a Test class that is overshadowing the system Test class.
Jamz_2010Jamz_2010

Sure, this is my method here:

 

 

lobal class orderConversion { WebService static void convertOrder(String sQuoteId) { Opportunity qteQuote = [SELECT Id, Name, AccountId, Account.Name, NimbusOM__Order_Number__c FROM Opportunity WHERE Id = :sQuoteId LIMIT 1]; activateAccount(qteQuote.AccountId); } private static Contract activateContract(String sQuoteId) { Contract conContract = [SELECT Id, Name FROM Contract WHERE NimbusOM__Quote_Reference__c = :sQuoteId LIMIT 1]; conContract.ActivatedDate = System.Now(); update conContract; return conContract; } static testMethod void testOrderConversion() { Test.StartTest(); convertOrder(qteTestQuote.Id); Test.StopTest(); }}

 

As you can see I don't do anything crazy here that should cause an error...

 

Thanks for this

 

James 

 

luckymeluckyme
The problem is not this class, but do you have a class (among all the classes you created) that is called 'Test'? If so, you need to rename it or it overshadows the system class 'Test'.
Jamz_2010Jamz_2010

Ah, got it. You were right (both of you :)). It was a class called test which superseded the standard test class.

 

Cheers for that

 

James