Skip to main content
6 risposte
  1. 13 giu 2017, 05:55
    Hi Arun Bikkasani,

    As Short and Sweet .. We faced in some situation ,

    1. you were using object but cannot be use in a tests, or doing some Http requests.

    2. In Such case there is no option, considered using " Test.isrunningTest() "

    3. This Static method allows you to discover the code was run from the test method.

               *⌗  return hardcoded String instead of calling http request and parsing the body

               * ⌗  return a fixed array of objects from a method  

    Example:- 

     

    Boolean error = testParsesResponse(response);

    if (Test.isRunningTest()) {

      error = false;

    } if (error) {

      alert('There is Some Problem Please Clean Up');

    ​ }

    the Unit test will never get into the error condition if(error), Because it's force to True in all unit Test's...

    Cheers !!!

    You can ask me if any doubts (Feel Free)...

    Regards,

    Soundar Raj