You need to sign in to do that
Don't have an account?
fiona gentry
How to resolve Illegal assignment from void to System.HttpsResponse in Test class
Hi folks,
How to resolve Illegal assignment from void to System.HttpsResponse in Test class
here is class
Thanks in advance
Fiona
How to resolve Illegal assignment from void to System.HttpsResponse in Test class
here is class
// Set mock callout class Test.setMock(HttpCalloutMock.class, new MockHttpResponseGeneratorAPI()); // Call method to test. // This causes a fake response to be sent // from the class that implements HttpCalloutMock. Test.starttest(); HerokuBanSync basicAcct = new HerokuBanSync(); basicAcct.getBANInfoUpdate('990135742'); Test.stoptest(); // Set mock callout class Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator()); // Call method to test. // This causes a fake response to be sent // from the class that implements HttpCalloutMock. HttpResponse res = basicAcct.getBANInfoUpdate('990135742'); // Verify response received contains fake values String contentType = res.getHeader('Content-Type'); System.assert(contentType == 'application/json'); String actualValue = res.getBody(); String expectedValue = '{"GSMStackableSOC__c":"false"}'; System.assertEquals(actualValue, expectedValue); System.assertEquals(200, res.getStatusCode());
Thanks in advance
Fiona
try to do with this method:-
@isTest
private class CalloutClassTest {
@isTest static void testCallout() {
Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
HttpResponse res = CalloutClass.getInfoFromExternalService();
String contentType = res.getHeader('Content-Type');
System.assert(contentType == 'application/json');
String actualValue = res.getBody();
String expectedValue = '{"example":"test"}';
System.assertEquals(actualValue, expectedValue);
System.assertEquals(200, res.getStatusCode());
}
}
I hope you find the above solution helpful. If it does, please mark it as the Best Answer to help others too.
Thanks and Regards,
Suraj Tripathi