Activity Forums Salesforce® Discussions What is mock test in Salesforce?

  • Anuj

    Member
    April 16, 2020 at 2:08 pm

    If your mock does return similar data to the real web service, then your tests can assert that your code that processes the response works correctly. You can also make the mock assert that you send the right request data out to the web service.
    Setting up a mock means you don't have to add a Test.isRunningTest() in your product code: changing the code under test just to test it is best avoided.
    If your code does no processing on the returned data then you are right it is a fairly pointless exercise.
    The main value of unit tests is that they check your implemented logic, and if you use Continuous Integration they can get run many times a day and alert you if when making one change you have broken existing logic. Coverage is just one measure of how well your tests are doing and is not a goal in itself. Personally I target 90% coverage overall.

    For More Details Click on the below link:
    https://developer.salesforce.com/blogs/developer-relations/2013/03/testing-apex-callouts-using-httpcalloutmock.html

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos