• Kiran S
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I am attempting to test the following callout method:
 
/******  CALLOUT  ******/
      public static HttpResponse MMarkAPIcallout(String domain){
        string endpoint = 'https://someapi.com/api/v5/company/dd/det?comp_id=';

        //get companyID using domain (this is a separate callout)
        string companyID = companyIDFetcher.companyIDFetcher(domain);

        //system.debug('companyID is' +companyID);
        httpRequest req = new httpRequest();


        req.setMethod('GET');

//set method as containing the endpoint + companyID
        req.setEndpoint(endpoint+companyID);

//set timeout
        req.setTimeout(120000);

        httpResponse res = new http().send(req);

        return res;
      }

And here's the test:
 
@isTest
private class MMarkAPITest {

    static testMethod void MMarkAPIUnitTest() {
        test.startTest();
        test.setMock(HttpCalloutMock.class, new MMarkAPITestHttpCalloutMock());

        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock.
        MMarkAPIcallout('company.com');

        test.stopTest();
    }

}

However, when I run this test from the classes menu in 'Setup' I get the following error and no test coverage:
 
system.nullpointerexception attempt to dereference a null object salesforce