You need to sign in to do that
Don't have an account?
How to Write a test method to cover Wrapper Class
I wrote a test method to cover code for the class shown below.
But its not covering the wrapper class .
please direct me to test wrapper class.
public with sharing class sno_in_table
{
public list<wrap> getRecords()
{
integer sno=1;
list<wrap>emps=new list<wrap>();
list<employee__c>emp_records=[select name,phone__c from employee__c];
for(employee__c em:emp_records)
{
emps.add(new wrap(sno,em));
sno++;
}
return emps;
}
//wrapper class
public class wrap
{
public integer sno{get;set;}
public employee__c emp{get;set;}
public wrap(integer sn, employee__c e)
{
emp=e;
sno=sn;
}
}
public static testmethod void m1()
{
sno_in_table sno=new sno_in_table();
sno.getrecords();
}
}
Hi
Integer int=56;
employee__c emp = new employee__c()
// if possible insert fields in this
sno_in_table.wrap cmp = new sno_in_table.wrap(int,emp);
Let me know any issue and if it solves ur problem plz accept it solution.
All Answers
Hi
U can create an object for wrapper class like
sno_in_table.wrap wp = new sno_in_table.wrap();
with that object u can call the methods which are under this wrapper class.
Let me know any issue and if it solves ur problem plz accept it solution.
@isTest
public static void testsno_in_table() {
employee__c obj = new employee__c();
obj.name='ram';
obj.phone__c=123456789;
insert obj;
sno_in_table sno=new sno_in_table();
sno.getRecords();
}
its showing error as
" Constructor not defined: [sno_in_table.wrap].<Constructor>()"
Hi
Integer int=56;
employee__c emp = new employee__c()
// if possible insert fields in this
sno_in_table.wrap cmp = new sno_in_table.wrap(int,emp);
Let me know any issue and if it solves ur problem plz accept it solution.
Hi,
Did anyone found the solution for this
its giving error.
Account_OrderedProjs_ListController.OppWrapper oo = new Account_OrderedProjs_ListController.OppWrapper();
Then you not get the error 'Constructor not defined'