Salesforce 2020 release has blocked all Apex tests that use http mocking

We have 100+ tests failing now that our main testing sandbox has received the 2020 release. We can no longer deploy. We’re getting many errors like

Unexpected error: You have uncommitted work pending

And custom errors such as

Failed to make request

implying that our tests are making http callouts, and not being mocked properly. These tests were previously passing without any org changes. What in the 2020 release could cause this behavior?

We are unable to find a minimum test case because running the whole test suite fails, but running individually failing tests pass.

Running tests in serial with Apex Test execution > Click Options > Disable Parallel Apex Testing has no effect

edit: this breaking change confirmed by other users

https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001oku&fId=0D53A00004feQ5K

In testing Summer ’20 in our sandboxes, there was an uptick in test failures around callouts.

and

We see some callout failures with message “System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out”

edit community report confirms https://success.salesforce.com/issues_view?id=a1p3A000000ATF1QAO

edit another bug report to signal boost https://success.salesforce.com/issues_view?id=a1p3A0000003UWIQA2

Answer

This should now be fixed, Summer ’20 patch 7 is live on almost all Summer 20 sandbox pods as of this edit

This was caused by an attempt to fix a different callout testing related bug in Summer ’20 (specifically, this one: https://success.salesforce.com/issues_view?id=a1p3A000000ATF1QAO) that clearly didn’t work as we had intended. That fix is being rolled back in Summer ’20 “patch 7”.

The patch release schedule can vary on multiple factors, but for most pods this should be live this week. You can check the current patch level of your pod from the sidebar of https://success.salesforce.com/issues_releases_view?release=226007000

Sorry for the hassle. We’re looking at what we can do for a revised fix to https://success.salesforce.com/issues_view?id=a1p3A000000ATF1QAO, but for the moment reverting the changes was the best option to unblock everybody.

Attribution
Source : Link , Question Author : Andy Ray , Answer Author : Community

Leave a Comment