You need to sign in to do that
Don't have an account?
Test method to cover Wrapper/Inner class
Hi,
I am unable to figure out how i can write test methods to cover code for my wrapper/inner class. It covers only 73 % and the highlighted (in red color) part is not covered. Can any one point me in the right direction?
public class showAsPDF_Cls {
List<Case> cs = new List<Case>();
Id Assid;
public class WrapperCases{
public Integer Count{set;get;}
public Case CaseDetails{set;get;}
}
public List<WrapperCases> wrapperlist = new List<WrapperCases>();
public showAsPDF_Cls(ApexPages.StandardController controller) {
Assid = apexPages.currentPage().getParameters().get('id');
cs = [select Serial_Number__c,Product_Lookup__c,Firmware_Version__c,CaseNumber,OwnerId,Status,CreatedDate,ClosedDate,Description,Resolution_Summary__c,DTS_c__c FROM Case where AssetId =: Assid order by CreatedDate ];
for(Integer i=0; i<cs.size();i++){
WrapperCases wp = new WrapperCases();
wp.Count= i+1;
wp.CaseDetails= cs[i];
wrapperlist.add(wp);
}
}
public List<WrapperCases> getList(){
return wrapperlist;
}
static testMethod void testPDF(){
Account acc = new Account(Name= 'Sample Acc');
insert acc;
pageReference p = system.CurrentPagereference();
p.getParameters().put('id',acc.Id);
Case c = new Case(status='test');
insert c;
WrapperCases w = New WrapperCases();
List<WrapperCases> wlist = new List<WrapperCases>();
w.count = 1;
w.CaseDetails= c;
wlist.add(w);
ApexPages.StandardController QController = new ApexPages.StandardController(c);
showAsPDF_Cls s = new showAsPDF_Cls(QController);
s.getList();
}
}
Any help is highly appreciated.
Thanks,
Kumar.
Update your test class to, Changed statements are in red font.
Thank you for the peply. I have done it.
Thank you,
kumar