You need to sign in to do that
Don't have an account?

Test method fails
HI,
I have test method and it's getting failing with this error : "System.Exception: No more than one executeBatch can be called from within a testmethod. Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation."
this is the case when I run test case in Full sandbox. I am not getting problems in Development Sandbox.
Any help on this would be appreciated.
Thanks
You don't need the runTestMethod boolean in your test class.
Change the runTestMethod in the batch apex to public visibility, then in your test method:
should do the trick.
All Answers
This sounds like the query backing your batch apex is returning more than 200 records - as you are getting this problem in a full sandbox, is the real data being pulled into the test?
I usually get around this by creating a Boolean testMode property in the batch apex class and setting this from the unit test. Then in the start method, if testMode is true I append a limit 200 to the query.
Hi Bob,
Boolean testMode property ? May I know how to use this.
I took a Boolean variable in the testclass and initialise it to true. where as in the Batch Apex, I took same variable and checking against true to append limit to the query. But I am getting system.NullPointer Exception. I know I am doing wrongly..
Can you help me how to do that?
Thanks in advance..
Can you post your code?
Here My Batch Apex:
and this is My Test Class:
You don't need the runTestMethod boolean in your test class.
Change the runTestMethod in the batch apex to public visibility, then in your test method:
should do the trick.
Thanks Bob.
Thanks a lot Mr. BOB,
It helped me too, smart solution..
Hi bob i met same scenario..
But whenever i call that static variable in my test method, it was raising the cause like "Class static variable cannot be accessed via object instance"..
what i do for this case.