I'm trying to deploy some code. I've tested everything in sandbox, verified unit tests pass and coverage is good. Created a changeset, uploaded to Prod. When I validate the changeset, I get 1 failure, with the following message:
Changeset "xxx" will not validate. One unit test fails with "An unexpected error occurred when trying to make a callout to the Box API. You have uncommitted work pending. Please commit or rollback before calling out
The exception is one I'm familiar with. You can't make an HTTP callout if you have DML pending (since the callout may fail or hang). However:
- The code was specifically designed to avoid this issue. I've hand checked the code to ensure there's no DML occurring before the callout.
- The same test passes in sandbox. I've double-checked that all relevant code is in the changeset.
The only thing I can think is that some of the unit test setup DML is "leaking" past the Test.startTest() call? Could this be a Spring 17 issue? I've opened a case, but client has Standard support; I expect it may be closed as "development issue". Has anyone else seen this variance between sandbox & validation?
Edit 1-Mar-17: At @DanielBallinger's suggestion I was able to capture a log of the failing test execution during the validation attempt. I see 3 pairs of DML_BEGIN/DML_END, and they are the three inserts I'm doing as part of my test setup; they all occur before Test.startTest(). I also scanned the log from test.startTest() to the error, looking for anything else (WF, etc) that could cause this; I see nothing. Further, none of the objects involved have any WF or Processes defined. It certainly looking like a platform issue.
And after 20 minutes on the phone with support, the case was closed because it's a "developer issue" and the client has Standard support.