1

A batchable class with a callout, using HttpCalloutMock in a testclass, doesn't seem to combine. (v29) This will throw an Callout Exception (“You have uncommitted work pending”). However no DML has taken place yet. When using a custom mock to run the Test, it will validate. I've created an unmanaged package that shows the issue: https://login.salesforce.com/packaging/installPackage.apexp?p0=04tb0000000MSlV

Comment out line 17 in TST_testBatch to see the problem occuring... Anyone ever encountered this? Looks like a Salesforce bug to me...

  • Do you have access to developer support? If so, raise a case and see what they say...If not, let me know, and I'll install the package, and raise a case - let's see if we can a definitive answer! – BritishBoyinDC Mar 25 '14 at 21:28
  • 1
    I've posted the issue to dev support. Needs some iterations to be fully understood (or reach the right lvl). If there is more relevant info on the issue, i'll post it here. – jheuvel Apr 3 '14 at 11:25
1

I've never gotten that combination to work - see here for a previous answer. You can try raising it - it would be great if it did work, but I have never seen documentation stating that it should work. They added more @future support for mock in 29, so hopefully there is more coming...

1

Known issue

I've received the following response from Salesforce support:

Tier 3 updated that this is a known issue in salesforce. It is at present tentatively scheduled to be fixed in Winter '15 (safe hover). You can raise a case after this release to check for the status of this bug.

So for now, creating your own custom mock seems to be the proper way to create tests for batchable classes with callouts...

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.