7

Starting recently we are now getting this error during tests:

Methods defined as TestMethod do not support Web service callouts

Rather than saying "Test Method Skipped" they are failing and causing deployments to not be able to complete.

The problem is that many of these are due to managed packages that do not implement protection from client tests and do not implement mock interface thus attempting to callout during test methods.

Is anyone else seeing this issue? Anyone found a fix.

Also, the stack trace string is simply blank in the test execution summary. The debug log show a managed package attempting to make a callout

Update Based on Crop's comment I thought I had a workaround BUT alas, the test is inserting / updating a record which causes the managed package to attempt a callout and since it is a trigger I have to have at least 1% coverage so I have to insert or update a record which causes the managed package triggers to fire....Oh vicious circle.

Update 2

I changed the old trigger to a process builder process which removed the need for the trigger. Still does not solve the problem if it was a more complex trigger....

Update 3

Implementing the managed Package mock response class still produces the error. It seems that a test.setMock within a local test does not get utilized by the namespaced class making the callout during a test.

10
  • when you deploy via changesets - you have the option to avoid running managed package tests (workaround)
    – cropredy
    Oct 21, 2015 at 23:38
  • @crop1645 - Thanks, unfortunately now I have to create a sandbox, etc, etc, etc as I was using MM to deploy directly to production...Will have to check how to set the setting in MM. As an aside, is this a bug or a new "Enhancement"
    – Eric
    Oct 21, 2015 at 23:42
  • I don't have your use case in my orgs but I can say that Winter 16 deployments now seem to exercise custom component controllers in VF email messages used in Approval Processes if you enter an Approval Process - and if said custom controller isn't tolerant of null values, it fails. Wasn't an issue in Summer 15 as the custom controller was never invoked. I think as with many SFDC releases, test behavior is not always guaranteed
    – cropredy
    Oct 21, 2015 at 23:45
  • @crop1645 - Unfortunately - that will not work as a test (local) inserts a record and the package makes a callout because of that record insert....ugh. I wish packages properly implemented mock interfaces......
    – Eric
    Oct 21, 2015 at 23:45
  • I know when I have built a package that uses callouts, I had to expose a global method in my package that sets the mock interface in my package as part of your setup to avoid this happening...this is going to get messy very quickly... Oct 27, 2015 at 22:42

1 Answer 1

8

Salesforce just posted an alert for partners about this, which is odd, this would normally be a known issue - and partner alerts generally don't go out for those.

I'll quote the most relevant bits here:

Who is impacted by this? Any partner whose org contained tests with callouts or calls to getContent before our recent Winter '16 patch release (patch 198.7).

What is the change? After a recent Winter ‘16 patch release, customers and partners may be seeing the following error message when running a test that attempts a callout or calls getContent, “Method defined as testMethod do not support web service callouts, test failed”.

Why is this change happening? Prior to this recent change, tests using callouts/Pagereference.getContent() were marked as "skipped". However, these tests NEVER worked, but never failed either. Deployments were allowed to proceed without fixing these tests.

As of patch 198.7, this behavior has been changed, such that these tests are now correctly marked as "failed" when executed.

What action do I need to take? If you and your customers are experiencing this, here are two recommended workarounds:

  1. Remove or comment out the tests that were previously being skipped. Please note that since those test classes have always been skipped, commenting them out now will not affect the other test classes nor reduce the testing done on the application upon deployment.

  2. Implement HTTP Callouts by implementing the HttpCalloutMock Interface. See this article on the Developer site for more information https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm

2
  • 4
    That is a huge misstep essentially rendering customers unable to deploy in some circumstances
    – Eric
    Oct 22, 2015 at 21:12
  • Yes that is how we discovered it as well, during an attempted deployment to production. Quite unsettling.
    – Adrian Larson
    Oct 27, 2015 at 22:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .