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
pp11222pp11222 

How to use isRunningTest from winter'11 new apex code features

I am trying to use the new system method "isRunningTest". This is introduced from winter'11.

 

isRunningTest

Return Type : Boolean

Description: Returns true if the currently executing code was called by code contained in a method isRunningTest Boolean defined as testMethod, false otherwise. Use this method if you need to run different code depending on whether it was  being called from a test.

 

I have added folloiwng to one of my apex trigger

 

system.debug(' isRunningTest : '  + system.isRunningTest());

 

I am getting this error:

 

Error: Compile Error: Method does not exist or incorrect signature: system.isRunningTest() at line.

 

I have set the API version to 20.0 and I am still getting the same error

 

Has anyone already tried using it in the apex code

thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
pp11222pp11222

It is a Documentation issue!

Should be:  Test.isRunningTest();

 

Found it here :

 

http://boards.developerforce.com/t5/Apex-Code-Development/API-Version-20-System-isRunningTest-Method-doesn-t-exist/m-p/207780#M36571