I have a
Batchable class which does a callout.
When I test the class which like this:
Test.startTest() MyBatchableJob job = new MyBatchableJob(); Database.executeBatch(job, 50); Test.stopTest();
I get this error:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out
But when I test like this:
Test.startTest(); MyBatchableJob job = new MyBatchableJob(); job.execute(null, [SELECT ... FROM ... ]); Test.stopTest();
It works fine.
Does creating and executing a
Batchable object using
Database.executeBatch count as pending uncommitted work? or am I missing something?