+ Start a Discussion
luccilucci 

Help me test clss for this wrapper class

Apexclass

--------------

public class accountwrapperclass
{
public list<accountwrapper> wrappers{get;set;}


public accountwrapperclass()
{
wrappers=new list<accountwrapper>();
wrappers.add(new accountwrapper());
}
public void addrow()
{
wrappers.add(new accountwrapper());
}
public void remove()
{

if(wrappers.size()>1)
wrappers.remove(wrappers.size()-1);

}
public void save()
{
list<account>acclist=new list<account>();
for(accountwrapper aw:wrappers)
{
acclist.add(aw.acc);
}
insert acclist;

}

public class accountwrapper
{
public account acc{get;set;}
public accountwrapper()
{
acc=new account();
}
}


}

 

test class

---------------

 

@istest
public class Accountwrapperclass_test{
static testMethod void validateTestMyClass() {
accountwrapperclass awc=new accountwrapperclass();

//awc.accountwrapper wrappers=new awc.accountwrapper();
//wrappers.acc.name='valli';
list<account> acclist=new list<account>();
for(account a:acclist){
a.Name='show';
acclist.add(a);
}
insert acclist;
delete acclist;
awc.save();
awc.remove();
awc.addrow();



}
}

 

I have only 70% codecoverage for that class.

 

public void addrow()
{
wrappers.add(new accountwrapper());
}
public void remove()
{

if(wrappers.size()>1)
wrappers.remove(wrappers.size()-1);

}

 

these lines are not cvered,

 

could pls anybody help me for increase code coverage

 

bob_buzzardbob_buzzard

I don't think this test class will be running, based on the fact that you have made your test class public.  From the docs:

 

--- snip ---

 

Methods of a public test class can only be called from a running test, that is, a test method or code invoked by a test method, and can't be called by a non-test request.

 

--- snip ---