test class written:
@IsTest
private class ExternalSearchTests {
@IsTest
static void testPositiveMocking() {
// GIVEN
HTTPMockFactory mock = new HTTPMockFactory(
200,
'OK',
'I found it!',
new Map<String, String>()
);
Test.setMock(HttpCalloutMock.class, mock);
// WHEN
Test.startTest();
String result = ExternalSearch.googleIt('epic search');
Test.stopTest();
// THEN
Assert.areEqual('I found it!', result, 'Expected to receive mock response');
}
@IsTest
static void testNegativeMocking(){
HTTPMockFactory hmock =new HTTPMockFactory(500,'Server Error', 'Not found', new Map<String, String>());
Test.setMock(HttpCalloutMock.class, hmock);
Test.startTest();
String result = ExternalSearch.googleIt('Ramsay');
Test.stopTest();
}
}
Challenge is not getting completed, is there any problem with the test class written?