function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sfdc11Sfdc11 

Urgent!! Http Webservice Test Class

Im gettin the folowing error when I abt to save the below test class for webservice class.
Method does not exist or incorrect signature: Test.setMock(Type, DMDMockHttpResponseGenerator) at line 5 column 8
 
@isTest
private class DMDCalloutClassTest {
     @isTest static void testDMDCallout() {
    
       Test.setMock(HttpCalloutMock.class,new DMDMockHttpResponseGenerator());
       
        HttpResponse res = Dmd_HttpCallTest.getCountryInfo();
       //HttpResponse res;
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/soap+xml; charset=utf-8');
        String actualValue = res.getBody();
        String expectedValue = '<birId>15625017</birId>';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
    }
}
 
 
 
@isTest
global class DMDMockHttpResponseGenerator implements HttpCalloutMock {
       
        global HTTPResponse respond(HTTPRequest req) {
        System.assertEquals('https://webservice/loc', req.getEndpoint());
        System.assertEquals('GET', req.getMethod());
       
        // Create a fake response
        HttpResponse res = new HttpResponse();
        res.setHeader('Content-Type','application/soap+xml; charset=utf-8');
        res.setBody('<birId>15625017</birId>');
        res.setStatusCode(200);
        return res;
    }
}
 
Please help me out!! 
Tim BarsottiTim Barsotti

Might want to try this: 

 

@isTest(seeAllData=true)
global class DMDCalloutClassTest {
     static testmethod void testDMDCallout() {
    
       Test.setMock(HttpCalloutMock.class,new DMDMockHttpResponseGenerator());
       
        HttpResponse res = Dmd_HttpCallTest.getCountryInfo();
       //HttpResponse res;
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/soap+xml; charset=utf-8');
        String actualValue = res.getBody();
        String expectedValue = '<birId>15625017</birId>';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());
    }
}