You need to sign in to do that
Don't have an account?
Rustyboy
How to overcome "Too many DML statement" when testing
I have written a test case which is attempting to get maximum coverage on a complex page. I now keep hitting the "Too many DML statements" problem. I get that what this is for, but I need to find a way of working around this for testing purposes.
Any ideas?
NB: I could resort to breaking my test into multiple classes, but that seems messy!
All Answers
Hi,
Please cross-check the apex code and trigger code make sure any DML operation not in loop,
and modify in the testmethod make block using Test.starttest() and test.Stoptest();
Hi,
You should use Test.startTest() and Test.stopTest() to overcome this problem. Please go through below URL, you will find it helpful.
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
Let me know if you have any specific question.
Happy to help you!
Thanks, but that is not the problem. I HAVE used Test.startTest() and Test.stopTest().
The problem is that of necessity I am making more than 150 DML calls to get the coverage.
Incidentally, it works fine when I break it into 2 separate classes, but I would rather not do this if I can avoid it.
Hi,
In that case, I guess you have to use 2 methods to achieve this.