BlackFriday 2024! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Exam Platform Developer II Topic 4 Question 103 Discussion

Actual exam question for Salesforce's Platform Developer II exam
Question #: 103
Topic #: 4
[All Platform Developer II Questions]

A developer has a test class that creates test data before making a mock callout but now receives a 'You have uncommitted work pending. Please commit or rollback before calling out' error.

Which step should be taken to resolve the error?

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Bernadine
28 days ago
Ah, the old 'You have uncommitted work pending' error. Brings back memories of that time I accidentally committed my entire life savings. Good times, good times.
upvoted 0 times
...
Hildegarde
29 days ago
I'm picking C, because I'm a rebel and I like to live on the edge. Commit? Who needs it?
upvoted 0 times
Kathrine
5 days ago
User3: I prefer option D, it's never let me down.
upvoted 0 times
...
Xenia
6 days ago
User2: I think C is the way to go, it's worked for me before.
upvoted 0 times
...
Quentin
11 days ago
I always go with option B to avoid that error.
upvoted 0 times
...
...
Donte
1 months ago
B is the way to go, my dude. Gotta keep that test data nice and tidy, you know?
upvoted 0 times
...
Gertude
1 months ago
Wait, so we have to commit or rollback before calling out? Sounds like a party trick to me.
upvoted 0 times
Cory
3 days ago
C) Ensure both the insertion and mock callout occur after the Test.startTest().
upvoted 0 times
...
Sophia
4 days ago
C: But why do we have to commit or rollback before calling out?
upvoted 0 times
...
Kattie
7 days ago
B) Ensure the records are Inserted before the Test.startTest() statement and the mock callout occurs within a method annotated with @testSetup.
upvoted 0 times
...
Carey
10 days ago
B: C) Ensure both the insertion and mock callout occur after the Test.startTest().
upvoted 0 times
...
Shonda
11 days ago
A: B) Ensure the records are Inserted before the Test.startTest() statement and the mock callout occurs within a method annotated with @testSetup.
upvoted 0 times
...
Maricela
18 days ago
A) Ensure both the Insertion and mock callout occur after the Test.startTest().
upvoted 0 times
...
...
Chun
1 months ago
I see your point, but I still think option B is the best choice based on the order of operations required to avoid the error message.
upvoted 0 times
...
Amalia
1 months ago
I disagree, I believe the answer is D. The records should be inserted before Test.startTest() and the mock callout should occur after Test.startTest().
upvoted 0 times
...
Chun
2 months ago
I think the correct step is B, because the records need to be inserted before Test.startTest() and the mock callout should be within a method annotated with @testSetup.
upvoted 0 times
...

Save Cancel