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

Not able to Achieve required coverage of a Trigger having nested If else conditions.
I have a trigger which having nested if and else conditions.If i use more DML soql then i am reaching the governor limit. I have only covered only 40%.So is there any alternative way of testmethod to cover Trigger coverage . Below is the sample code of trigger.Please help me its very urgent.
If(E.whoid==Eold.whoid)
{
if(Unew[0].FirstName=='Abhey')
{
if(Tnew.size()>0)
{
if(EO1.size()>0)
{
if(Uold[0].FirstName=='Heather')
{
if(Told.size()>0)
{
if(EO2.size()>0)
{
if(EO2[0].ActivityDate >= Told[0].ActivityDate)
{
}
else
{
}
}
Thanks.
You can write more than one method in Test Class so in one method you can write up to 20 DML statements and since this test method needs more than 20 DML statements so you create another method. There is no limit on number of methods and number of lines in a test method so you will never hit the governor limit by this way.
Find below a sample code -
@isTest
private class MyTestClass
{
static testmethod void MyTestMethod1()
{
// here write your code up to 20 DML
}
static testmethod void MyTestMethod2()
{
// here write your code up to 20 DML
}
static testmethod void MyTestMethod3()
{
// here write your code up to 20 DML
}
}
All Answers
You should probably post the entire tirgger and the test method you have written.
You can write more than one method in Test Class so in one method you can write up to 20 DML statements and since this test method needs more than 20 DML statements so you create another method. There is no limit on number of methods and number of lines in a test method so you will never hit the governor limit by this way.
Find below a sample code -
@isTest
private class MyTestClass
{
static testmethod void MyTestMethod1()
{
// here write your code up to 20 DML
}
static testmethod void MyTestMethod2()
{
// here write your code up to 20 DML
}
static testmethod void MyTestMethod3()
{
// here write your code up to 20 DML
}
}