Activity Forums Salesforce® Discussions What does Test.isRunningTest() identifies in the Apex class in Salesforce?

  • What does Test.isRunningTest() identifies in the Apex class in Salesforce?

    Posted by Anjali on September 4, 2020 at 10:46 am

    What does Test.isRunningTest() identifies in the Apex class in Salesforce?

    Shweta replied 4 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Shweta

    Member
    September 4, 2020 at 2:38 pm

    Test.isRunningTest(): This method is used to identify if the piece of code being executed is invoked from a Test class execution or from other artefacts such as a Trigger, Batch Job etc. Returns true if the code being executed is invoked from a test class otherwise returns a false.
    This method usually comes in handy, when you intend to conditionally restrict execution of certain Apex code blocks, based on whether they are being invoked from a test class or not.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos