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

Test class at 72% need small help to increase
Hi all,
The following code is almost covered but I need some help with covering some of the code that I dont know how to right coverage for. Below is the class and test class in the class there is reference to disablexxx = true; and xxxQuoteValue = true; I need to cover these in my test class. There is an attempt to cover in the test class but something is not written right.
Any help would be great.
Class: disableAuto and such refers to items on my vf page.
if(l.Consumer_Products__c == auto) { disableAuto = true; disableHome = true; disableUmbrella = true; disableBoat = true; disableDwellingFire = true; disableThirdParty = true; autoQuoteValue = true; }
test class: note the "clc.autoQuoteValue = true;" running test shows that it is not covered.
ApexPages.currentPage().getParameters().put('id', lead.Id); ApexPages.StandardController sc = new ApexPages.StandardController(lead); Test.startTest(); ConvertLeadController clc = new ConvertLeadController(sc); clc.autoQuoteValue = true; clc.boatQuoteValue = true; clc.dwellingFireQuoteValue = true; clc.homeQuoteValue = true; clc.thirdPartyQuoteValue = true; clc.convertLead();
Thanks in Advance,
Dwayne
If you have further 'Consumer_Products__c ==' statements you need covered, then yes, you'll need to insert/update a lead for each execution path (each 'if' statement)
All Answers
Hey Dwayne-
Could you post some additional code? Looking at your test class, it doesn't appear you ever set the field l.Consumer_Products__c equal to 'auto'. So this line in the test class:
appears as if it would return false.
Kevin,
Thanks for taking a look. Here is the first part of the test class up to and including the part I need help with.
Kevin,
So sorry I posted the controller class. Please see below for the test class.
Without knowing what else your'e doing in the test class, it doesn't look like you're ever explicitly setting Consumer_Products__c.
You can drop a system.debug in before that if statement, something like:
system.debug('Consumer_Products__c==================' + l.Consumer_Products__c);
and take a look in the debug log and see what the value is before the conditional (IF) fires.
Yup, its never equal to the static variable 'auto', so its never going to fire.
ahh the light bulb goes on. I guess my next question would be, since it needs to test again 6 difference possible instances of Consumer_Product, if I add the Auto would that cover the other potential instances?
If you have further 'Consumer_Products__c ==' statements you need covered, then yes, you'll need to insert/update a lead for each execution path (each 'if' statement)
Yes light bulb is as bright as the sun. Thank you so much for your help. I will added the needed code to the test class.