You need to sign in to do that
Don't have an account?
vijendhar
How to cover these code in test class, i can not cover all adderror mehods, how to handle all if statements in single list of data with different conditions
Hi all,
can u help me to cover all adderror with differnt conditions frm same unit test method, its on opportunity object
if(service == 'Starter' && opp.Initial_Cost__ < 0){
opp.addError('Cannot close the Opportunity since setup fees is less than 0.initialcost');
}
if(service == 'Social' && initialcost < 0){
opp.addError('Cannot close the Opportunity since setup fees is less than 0.initialcost');
}
if(service == 'Reputation Builder' && initialcost < 0){
opp.addError('Cannot close the Opportunity since setup fees is less than 0.initialcost');
}
if(service == 'Media' && initialcost < 375){
opp.addError('Cannot close the Opportunity since setup fees is less than 375.initialcost');
}
if(service == 'Premium' && initialcost < 425){
opp.addError('Cannot close the Opportunity since setup fees is less than 425.initialcost');
}
if(service == 'Velocity' && initialcost < 500){
opp.addError('Cannot close the Opportunity since setup fees is less than 500.initialcost');
}
if(service == 'Dominator' && initialcost < 650){
opp.addError('Cannot close the Opportunity since setup fees is less than 650.initialcost');
}
can u help me to cover all adderror with differnt conditions frm same unit test method, its on opportunity object
if(service == 'Starter' && opp.Initial_Cost__ < 0){
opp.addError('Cannot close the Opportunity since setup fees is less than 0.initialcost');
}
if(service == 'Social' && initialcost < 0){
opp.addError('Cannot close the Opportunity since setup fees is less than 0.initialcost');
}
if(service == 'Reputation Builder' && initialcost < 0){
opp.addError('Cannot close the Opportunity since setup fees is less than 0.initialcost');
}
if(service == 'Media' && initialcost < 375){
opp.addError('Cannot close the Opportunity since setup fees is less than 375.initialcost');
}
if(service == 'Premium' && initialcost < 425){
opp.addError('Cannot close the Opportunity since setup fees is less than 425.initialcost');
}
if(service == 'Velocity' && initialcost < 500){
opp.addError('Cannot close the Opportunity since setup fees is less than 500.initialcost');
}
if(service == 'Dominator' && initialcost < 650){
opp.addError('Cannot close the Opportunity since setup fees is less than 650.initialcost');
}
@Karanraj
I highly recommend you to create test methods for each and every scenario, create seperat methods in your test class for the each if conditions to statisfy
Chandra Sekhar CH N V
You need to create test records in such a way that it will cause the error to throw.