Salesforce
PDII · Question #211
A developer has a test class that creates test data before making a mock call-out, but now receives a `榊ou have uncommitted work pending. Please commit or rollback before calling out' error. What…
The correct answer is D. Ensure the records are inserted before the Test.startTest() statement and the mock callout after. See the full explanation below for the reasoning.
Question
A developer has a test class that creates test data before making a mock call-out, but now receives a `榊ou have uncommitted work pending. Please commit or rollback before calling out' error. What step should be taken to resolve the error?
Options
- AEnsure both the insertion and mock callout occur after the Test.startTest()
- BEnsure both the insertion and mock callout occur after the Test.stopTest()
- CEnsure the records are inserted before the Test.startTest() statement and the mock callout occurs
- DEnsure the records are inserted before the Test.startTest() statement and the mock callout after
How the community answered
(60 responses)- A12% (7)
- B5% (3)
- C3% (2)
- D80% (48)
Community Discussion
No community discussion yet for this question.