ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 7 - Certified Platform Developer II discussion

Report
Export

@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.
Answers
A.
Add if (!Test.isRunningTest()) around CalloutUtil.sendAccountUpdate.
B.
Add Test.startTest() before and Test.stopTest() after CalloutUtil.sendAccountUpdate.
Answers
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.
Answers
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.
Answers
D.
Add Test.startTest() and Test.setMock before and Test.stopTest() after CalloutUtil.sendAccountUpdate.
Suggested answer: B
asked 23/09/2024
Mithun E
50 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first