1 answer
Hi Alias,First Create the Test Sample data like this:- @isTest global class MockHttpResponseGenerator implements HttpCalloutMock { global HTTPResponse respond(HTTPRequest req){ try{ if(req.getEndpoint()=='https://any_endpoint_here.com'){ HttpResponse res= new HttpResponse(); res.setHeader('Content-Type','application/json'); res.setBody('{"Name ":"Test Name"}'); res.setStatusCode(200); return res; } }catch(Exception ex){ System.debug('ERROR Message>>>'+ex.getMessage()+' Error Line Number>>> '+ex.getLineNumber()); } return null; } }Below test class works fine please this out:-@isTest private class TestClassForClassSetupApex { @isTest static void testCallout(){ Test.setMock(HttpCalloutMock.Class, new MockHttpResponseGenerator()); Class_Name.getMethod('TestName'); } }Hope this explanation will resolve your query. Mark it as the best answer if you find it helpful.ThanksAkshay