nerdexam
Salesforce

PDII · Question #1

The test method above calls a web service that updates an external system with Account information and sets the Account's Integration_Updated__c checkbox to True when it completes. The test fails to…

The correct answer is B. Add Test.startTest() and Test.setMock before and Test.stopTest() after. See the full explanation below for the reasoning.

Question

The test method above calls a web service that updates an external system with Account information and sets the Account's Integration_Updated__c checkbox to True when it completes. The test fails to execute and exits with an error:

"Methods defined as TestMethod do not support Web service callouts." What is the optimal way to fix this?

Options

  • AAdd Test.startTest() before and Test.setMock and Test.stopTest() after
  • BAdd Test.startTest() and Test.setMock before and Test.stopTest() after
  • CAdd if (!Test.isRunningTest()) around CalloutUtil.sendAccountUpdate.
  • DAdd Test.startTest() before and Test.stopTest() after CalloutUtil.sendAccountUpdate.

How the community answered

(18 responses)
  • A
    6% (1)
  • B
    78% (14)
  • C
    11% (2)
  • D
    6% (1)

Community Discussion

No community discussion yet for this question.

Full PDII Practice