What is the optimal...
 
Notifications
Clear all

What is the optimal way to fix this?

1 Posts
1 Users
0 Likes
60 Views
Isaiah
(@casausisaiah)
Noble Member
Joined: 7 months ago
Posts: 354
Topic starter  

@isTest static void testAccountUpdate() { Account acct = new Account({Name = 'Test'); acct.Integration Updated_c = false; insert acct; CalloutUtil.sendAccountUpdate (acct.Id); Account acctAfter = [SELECT Id, Integration Updated_c FROM Account WHERE Id = :acct.Id] [0]; System.assert(true, acctAfter.Integration_Updated_c); } 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?

  • A . Add if (!Test.isRunningTest()) around CalloutUtil.sendAccountUpdate.
  • B . Add Test.startTest() before and Test.stopTest() after CalloutUtil.sendAccountUpdate.
  • C . Add Test.startTest() before and Test.setMock and Test.stopTest() after CalloutUtil.sendAccountUpdate.
  • D . Add Test.startTest() and Test.setMock before and Test.stopTest() after CalloutUtil.sendAccountUpdate.

Show Answer Hide Answer

Suggested Answer: B

   
Quote
Share: