You need to sign in to do that
Don't have an account?
a!
Test code coverage
public with sharing class account_name { public list<account> accounts=new List<Account>(); Account acc_con=new Account(); public Account getaccdet() { return acc_con; } public account_name() { } public class innerClass { public Account accc{get; set;} public Integer UniqId{get;set;} } public List<innerClass> IList = new List<innerClass>(); public Integer i=0; public void add() { innerclass inn=new innerclass(); Account acc_det=new Account(); acc_det.Name=acc_con.Name; acc_det.Industry=acc_con.Industry; acc_det.Phone=acc_con.Phone; i++; inn.accc=acc_det; inn.uniqid=i; System.debug('******'+inn); IList.add(inn); System.debug('iiii'+IList); acc_con=new account(); } public List<innerClass> getAlist() { return IList; } public void save1() { List<Account> insertaccount = new List<Account>(); for(InnerClass IPs : iLIst) { //IPs.accc.AccouontId=acc_con.id; insertaccount.add(IPs.accc); System.debug('//////'+insertaccount); } insert insertaccount; } public void deleteITem() { String i=System.CurrentPageReference().getParameters().get('aid'); System.debug('/////'+i); Integer k = 0; boolean b = true; for(InnerClass IP : IList) { System.debug('*************'+IP.uniqid); if(IP.uniqid==Integer.valueOf(System.CurrentPageReference().getParameters().get('aid'))) { b=false; break; } k++; } if(!b) { IList.remove(k); } } //--------------Test Method--------------// public static testmethod void test() { account_name obj=new account_name(); obj.getaccdet(); obj.add(); obj.getAlist(); obj.save1(); obj.deleteITem(); } }
Hi
public void deleteITem() { String i=System.CurrentPageReference().getParameters().get('aid'); System.debug('/////'+i); Integer k = 0; boolean b = true; for(InnerClass IP : IList) { System.debug('*************'+IP.uniqid); if(IP.uniqid==Integer.valueOf(System.CurrentPageReference().getParameters().get('aid'))) { b=false; break; } k++; } if(!b) { IList.remove(k); } }
am not covering the above code in the test class, plese look at this
Thanks in Advance
Hi,
try this.....
In Test method.
Id this does not solves your problem please post you code by Highlighting (which is not covered).
above code is not covered in the test class.