7

Our org got upgraded to winter 16 last Friday October 16. When I used to run all test few tests were failing with error: Methods defined as TestMethod do not support Web service callouts

however, now when I am trying to deploy/validate I am receiving the same error. have any one started facing this issue ? any recommendations? Do I need to modify all my test classes affected by this error?

5

Deployment changed in winter 15' introducing testLevel, make sure you are setting it to NoTestRun, They might have changed the default level as in winter 15' it was set to NoTestRun but this could now have changed. Check your deployment and validation routines.

** UPDATE Critical Update in the Winter '16 Release

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

|improve this answer|||||
  • Yeah, now default level is running local tests – C0DEPirate Oct 22 '15 at 6:57
  • updated answer for you, Hope it helps – TimChadwick Oct 22 '15 at 11:11
6

My org is experiencing the same issue after our upgrade to Winter 16.

The old error message of: Method defined as testMethod do not support web service callouts, test skipped is now giving an Test Failed message. This is happening during both deployments and with running the test class manually.

We have fixed our test classes and are no longer getting the error.

The correct way to write callout test classes is with Mocking: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm

|improve this answer|||||
  • Thank you @lunadog I have modified my test classes just wanted to check what was the reason for this behavior. – C0DEPirate Oct 20 '15 at 5:59
4

I have contacted salesforce about this and got the below response:

This behavior was not observed in the past because Salesforce use to skipped these type of test classes before Winter'16 but from this point on they will be flagged as failures like it should have done even before ( existing behavior ) . This was the modification that was addressed in one of our patches from Winter'16 release.

So In order for the deployment to go through, you can either comment out the test classes, remove the @isTest annottation or take off the testMethod modified and deployment should go through.

Please not that since those test classes were skipped all this time, commenting them out now will not affect the other test classes . In the long term, you will have to do a code review and make sure that callouts are not being made from test classes. Instead you can use the webservice mock interface to mimic the same functionality.

This is working as designed as per the new Winter'16 release.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.