function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MmehtabMmehtab 

Test class for Controllers with Wrapper Methods not enough coverage

I have controller classes with Wrappers and am unable to the wrapper methods where the selected box=True. User-added imageUser-added image

I am new to apex and not sure how to access the wrapper in a way to be able to cover the lines of code in red. Any help is appreciated.
Thanks!
 
Pramodh KumarPramodh Kumar
Hi,

use this code 
list<ExpenseReportController.corpCardTranswrapper> tcList = new list<ExpenseReportController.corpCardTranswrapper>();
for(ExpenseReportController.corpCardTranswrapper tc: extension.corpCardTransList) {
        	tc.selected = true;
        	tcList.add(tc);
        }
extension.corpCardTransList = tcList;

Thanks,
pRAMODH.
MmehtabMmehtab
Pramodh,
I get a 'variable is not visible' error for the corpCardTransList. Should this be a public list?
Thanks!
Pramodh KumarPramodh Kumar
Yeah it must be public variable.