Activity Forums Salesforce® Discussions What does (!test.isRunningTest()) signifies in Salesforce?

  • Prachi

    Member
    August 1, 2018 at 7:22 am

    Hello Chancal,

    The Test.isRunningTest() 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.

    ! is the Logical complement operator. Inverts the value of a Boolean, so that true becomes false, and false becomes true.

    So,  (!test.isRunningTest()) will Return false if the code being executed is invoked from a test class otherwise returns a true.

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos