14

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

6
  • 2
    Can you post a simple MVR (Minimal Viable Reproduction) that demonstrates this issue? Ideally, we should be able to easily replicate this problem. None of our tests are failing, so it's clearly not a global thing. Maybe how your test is written?
    – sfdcfox
    Jun 2, 2020 at 4:51
  • 1
    Is that possible that tests run in parallel? Can you try to run them in serial mode?
    – kurunve
    Jun 2, 2020 at 6:32
  • You need to disable it from salesforce setup, look for Apex Test execution. Click Options. In the Apex Test Execution Options dialog, select Disable Parallel Apex Testing and then click OK.
    – Raul
    Jun 2, 2020 at 7:14
  • Can you post an example test that's failing? I'd like to see how your mocking
    – Kevin P
    Jun 2, 2020 at 10:47
  • @sfdcfox I always appreciate your help. This issue has been reported by 56 users and counting success.salesforce.com/issues_view?id=a1p3A000000ATF1QAO - I worry your first reply is misleading and I don't understand your conclusion that it's not a global thing
    – Andy Ray
    Jun 2, 2020 at 17:10

2 Answers 2

13

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.

6
  • 3
    Thank you for directly reaching out to the community. I can accept this once we start seeing fixes. This is currently blocking all feature work as our tests are required for both feature merges and deploys, so if you can expedite this fix, that would be great.
    – Andy Ray
    Jun 2, 2020 at 18:24
  • We had to refresh our sandbox that runs unit tests for our builds and ticks our PRs, but we have other Summer '20 boxes so we can keep retesting.
    – markgarg
    Jun 2, 2020 at 19:16
  • @AndyRay "patch 7" looks to be live now for all sandboxes that are on Summer unless I'm missing something. (it was not as of the time of your posting though) Jun 3, 2020 at 1:35
  • @ca_peterson why does this issue no longer appear in the list on the link in your ticket: success.salesforce.com/issues_releases_view?release=226007000 ? or was it ever there?
    – Andy Ray
    Jun 15, 2020 at 16:42
  • @AndyRay it was never there, I posted that link for the sidebar to track the release. There wasn't a public KI for this - we focused on expediting the fix instead once we knew how widespread the issue was. Jun 17, 2020 at 19:30
2

We were able to fix breaking tests that occurred only during our full regression deployments by encapsulating the class that performed the http callout with System.Test.startTest() and System.Test.stopTest() actions.

We were performing http mock callouts as the very first action in @testSetup methods, so "System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out" should not have occurred.

When our builds do deployments, we execute a full regression test. The tests were only breaking during a full regression test and only when deploying against sandboxes with the Summer '20 preview. The deployment package with unmodified tests was able to validate successfully against our Spring '20 production org.

You must log in to answer this question.

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