Salesforce Apex: test that callout hasn't been made -
i want write unit test checks callout hasn't been made trigger.
know how test if callout made correctly - implementing httpcalloutmock:
global class myhttpcalloutmock implements httpcalloutmock { global httpresponse respond(httprequest req) { //test httprequest here } }
but if no http request made, respond() method won't called. approach doesn't test if request made @ all.
need this:
httprequest.assertnorequestshavebeenmade();
how do that?
so figured out. turns out salesforce has methods test.starttest()
, test.stoptest()
make asynchronous callouts synchronous: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_tools_start_stop_test.htm
after making callouts synchronous it's easier test them.
Comments
Post a Comment