Salesforce Certified Application Architect

Wednesday, 25 November 2015

Understanding the usage of Test.isRunningTest()

Test.isRunningTest() :

1.This is not used in test classes but in other classes in order to verify if the call is from a test class.
2.Test.isRunningTest() is used to define whether the code is executed by test class.

Example :

public String Test(){
    // Build the http request
    // Invoke web service call
    String result = '';
    if (!Test.isRunningTest()){
        // Make a real callout since we are not running a test
    } else {
        // A test is running
        result = Response;
    }
    return result;
}

No comments:

Post a Comment

Salesforce Certified Application Architect & Certified Data Architecture and Management Designer Exam

How to pass Salesforce Certified Data Architecture and Management Designer Exam This exam was 1st architect exam for me. Its not that muc...