• lily wu 9
  • NEWBIE
  • 5 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi,

I'm working on the ExternalSearch_Tests Apex class and trying to get my negative scenario to pass, but it won't.  I know my logic isn't correct so may I get some help? (Technical pointers and not necessarily the answer.  I'll figure it out.  I'm not sure what I'm doing being still a beginner with Apex.  Thanks)

@isTest static void test_method_negative() {
    HttpMockFactory mock = new HttpMockFactory(500, 'Internal Server Error', 'Did not recieve a 200 status code: ', new Map<String,String>());
    Test.setMock(HttpCalloutMock.class, mock);
    String result;
    Test.startTest();
      result = ExternalSearch.googleIt('!');
    Test.stopTest();
    system.assertEquals('Did not recieve a 200 status code: ', result); 
  }

Reference trailhead "Unit Testing on the Lightning Platform (https://trailhead.salesforce.com/en/content/learn/modules/unit-testing-on-the-lightning-platform" style="color:#0563c1; text-decoration:underline)" - module "Use Mocks and Stub Objects".