I am trying to write a test class for a @future method which makes a REST callout whose response is just 200 {"status" : "ok"}. It does not make any updates to records. I am finding it difficult to assert the test. I do have a mockResponse but not able to access it as the method it void.

 public static void deleteLogCallout() {
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setHeader('x-api-key', 'xyz');
    private static void testDeleteLog() {

        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());

Does anyone have any ideas on how to write the asserts for it?

1 Answer 1


In unit tests, you generally make assertions on the output and the result of running a piece of code.

Given the name of the thing you're testing (Chatlog.deleteLog()), I'd assume there is a chat log you should be deleting. You want to assert that the intended log is actually deleted (done by querying before and after running the target piece of code) if that log is stored in Salesforce.

As for the callout, the only things we should test are the things that we have control over (and within Salesforce). That means the callout process and the logic run by that third party service are out of scope for this test. About the only thing that you do have control over here is whether a callout is made or not.

You can make an assertion against whether a callout was made or not (use Limits.getCallouts() before and after, or have your mock set a static variable that you can check).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .