Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Certified Platform Developer II (Plat-Dev-301) Exam - Topic 1 Question 109 Discussion

Actual exam question for Salesforce's Salesforce Certified Platform Developer II (Plat-Dev-301) exam
Question #: 109
Topic #: 1
[All Salesforce Certified Platform Developer II (Plat-Dev-301) Questions]

Refer to the test method below''

The test method calls a web service that updates an external system with Account

information and sets the Accounts 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.''

A)

B)

C)

D)

Show Suggested Answer Hide Answer
Suggested Answer: C

The correct feature to use is C, Named Credentials. Named Credentials are a secure way of storing the endpoint and authentication details for callouts to external services. When URLs change frequently, using Named Credentials allows you to manage the endpoint URL in one place without changing the Apex code.


Named Credentials

Contribute your Thoughts:

0/2000 characters
Nathalie
4 months ago
Just use @isTest(SeeAllData=false) to avoid this issue!
upvoted 0 times
...
Asuncion
4 months ago
Hmm, I thought there was a way around that.
upvoted 0 times
...
Cheryl
4 months ago
Wait, are you serious? I thought we could mock those calls.
upvoted 0 times
...
Jacob
4 months ago
Totally agree, that's why it failed!
upvoted 0 times
...
Brynn
5 months ago
Test methods can't do web service callouts, that's a fact.
upvoted 0 times
...
Carman
5 months ago
I feel like I saw a similar question in our last review session, but I can't remember which option was the correct one.
upvoted 0 times
...
Pa
5 months ago
I think the error message is telling us that we need to use a mock class, but I can't recall the exact syntax for it.
upvoted 0 times
...
Hollis
5 months ago
This reminds me of a practice question where we had to use HttpCalloutMock to simulate the web service response.
upvoted 0 times
...
Lawanda
5 months ago
I remember that test methods can't make actual web service callouts, but I'm not sure how to mock them properly.
upvoted 0 times
...
Elenore
5 months ago
I've seen this kind of issue before. The solution is probably to use a test double or mock object to simulate the web service call, rather than actually making the call in the test method.
upvoted 0 times
...
Yoko
5 months ago
This is a good one. The key is to find a way to test the functionality without actually making the web service call. I'll need to look into some Salesforce testing best practices to figure this out.
upvoted 0 times
...
Maile
5 months ago
Okay, I think I know what's going on here. The test method is trying to do something that's not supported, so I'll need to find a way to mock or simulate the web service call instead.
upvoted 0 times
...
Glynda
5 months ago
I'm a bit confused by this one. The test method is trying to update an external system, but that's not allowed in a test method. I'll need to think carefully about how to approach this.
upvoted 0 times
...
Latricia
6 months ago
Hmm, this looks tricky. The error message says the test method doesn't support web service callouts, so I'll need to find a way around that.
upvoted 0 times
...
Bettina
11 months ago
Seriously, who writes these exam questions? 'Methods defined as TestMethod do not support Web service callouts' - it's like they're trying to trip us up! *rolls eyes*
upvoted 0 times
Benton
9 months ago
Yeah, I agree. It's definitely a tricky one, but I think you're onto something with Option A.
upvoted 0 times
...
Gerald
10 months ago
I think the answer might be Option A, because TestMethod doesn't support Web service callouts.
upvoted 0 times
...
Hollis
10 months ago
I know right, it's so frustrating when they try to trick us with these kind of questions.
upvoted 0 times
...
...
Melinda
11 months ago
Option B looks like the way to go. Separating the web service call into a different method seems like the obvious solution here.
upvoted 0 times
Rosio
9 months ago
Great point! Option B is the way to go to fix the error with the TestMethod.
upvoted 0 times
...
Rolland
10 months ago
Definitely, moving the web service call to a separate method is a common practice to avoid issues with TestMethods.
upvoted 0 times
...
Whitley
10 months ago
I agree, Option B seems like the most logical solution in this scenario.
upvoted 0 times
...
Chaya
11 months ago
Option B is a good choice. Separating the web service call into a different method can help resolve the issue.
upvoted 0 times
...
...
Larae
11 months ago
Ah, I see the issue now. We need to move the web service call out of the test method and into a separate method. *chuckles* Rookie mistake, am I right?
upvoted 0 times
...
Silva
11 months ago
Wait, did they just say 'Methods defined as TestMethod do not support Web service callouts'? That's a pretty clear error message if you ask me.
upvoted 0 times
...
Clare
11 months ago
I believe we can use a mock callout to simulate the web service response and make the test method pass.
upvoted 0 times
...
Meghan
11 months ago
Hmm, looks like we can't use web service callouts in test methods. Guess we'll have to find another way to test this functionality.
upvoted 0 times
Clarinda
10 months ago
Definitely. Let's refactor our test method to use a mock callout and see if that resolves the issue.
upvoted 0 times
...
Junita
10 months ago
I agree. It's important to find alternative ways to test our code when certain limitations exist.
upvoted 0 times
...
Leonor
11 months ago
That's a good idea. Mock callouts will allow us to test the functionality without actually making a web service call.
upvoted 0 times
...
Lasandra
11 months ago
We can try using a mock callout instead of a real one.
upvoted 0 times
...
...
Craig
12 months ago
I agree with Geoffrey. We need to find a way to handle the web service callouts in the test method.
upvoted 0 times
...
Geoffrey
12 months ago
I think the error is due to the test method not supporting web service callouts.
upvoted 0 times
...

Save Cancel