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
arun rupesharun rupesh 

I want test class for below wrapper class

Hi,

i want test class for below wrapper class

public class Accountwrapper {
    
    // variable
    public list<acwrap> Acclist{get;set;}
     public list<Account> selectlist{get;set;}
   // Contructor 
    public Accountwrapper(){
        Acclist=new list<acwrap>();
        for(Account a:[select id,name,AccountNumber from Account]){
            Acclist.add(new acwrap(a));
        }
    }
    // Method
    public void selected(){
        selectlist=new list<Account>();
        for(acwrap a1:Acclist){
            if(a1.ischeck==true){
               selectlist.add(a1.acc) ;
            }
        }
        
    }
    public class acwrap{
        public Account acc{get;set;}
        public boolean ischeck{get;set;}
        public acwrap(Account ac){
            this.acc=ac;
            ischeck=false;
        }
    }
}
Best Answer chosen by arun rupesh
Suraj TripathiSuraj Tripathi
Hi arun,

You can try the following test class it covers 93% code coverage and also the wrapper class
@isTest
public class Accountwrapper_Test {
    @isTest public static void AccountTest(){
        Account acc=new Account();
        acc.Name='abcd';
        acc.AccountNumber='123456';
        insert acc;
        
        Accountwrapper accObj =new Accountwrapper();
        accObj.selected();
        
    }
}

Hope this helps you.

Regards,
Suraj