You need to sign in to do that
Don't have an account?
dmcheng
Winter 13 setMock callout fails for trigger / future method unit test
In case anyone is trying the new HttpCalloutMock to test a trigger -> future method -> callout method combination: i'm getting the same "uncommitted work pending" error as described in this thread:
This is occurring even when the only DML in my test code is the DML needed to fire the trigger.
The trigger and methods are working fine at the UI level, just not in unit tests.
Take a look at the Salesforce Stack Exchange as well - lot's of posts about it, not many answers - seems to be a significant flaw in the design...
http://salesforce.stackexchange.com/search?q=mock
I also saw a post about deployment where support suggested moving all the callout classes to the top of the list (by changing the name no less) as it will fail if you try and make callouts after tests that invoke DML in the same deployment?
Ran into the same problem and by prefixing the callout classes with AAA, causing them to be at the top of the list as suggested above, we are not seeing the error anymore.
So all you did was rename your callout classes by prefixing AAA, and it worked? You didn't have to modify anything in the unit test code as far as re-ordering your data insert statements or callout statements, etc?
Yes, we prefixed the test class that was doing the mock callout, making that the first test that is run, and that caused the test to pass.