You need to sign in to do that
Don't have an account?

Test class for wrapper class
Hi,
I need to write test class for wrapper class coverage.
CLASS
----------
public without sharing class OppController {
public OppController() {
}
private class wrapOpp {
public Integer index { get; set; }
public Opportunity opp {get; set;}
public String error {get; set; }
public List<SelectOption> allEquipments {
get {
List<SelectOption> Equipments = new List<SelectOption>();
Equipments = OppUtil.allEquipmentOptions;
return Equipments;
}
}
public List<SelectOption> allNotifyDates {
get {
List<SelectOption> NotifyDates = new List<SelectOption>();
if(opp.Property__c != null) {
NotifyDates = OppUtil.allNotifyDateOptions.get(opp.Equipment__c);
}
return NotifyDates;
}
}
private wrapOpp(Integer ndx, Opportunity o, String err) {
index = ndx;
opp = o;
error = err;
}
}
}
TEST CLASS (wrapper line)
-------------------------------------
public class testOppclass{
public static testmethod void TestOppMethod(){
OppController.wrapperOpp Wrapvar = new OppController.wrapperOpp();
}
}
When I declare a variable I am getting error message as
" Type not visible ; OppController.wrapperOpp" on the line "OppController.wrapperOpp Wrapvar = new OppController.wrapperOpp();"
Please help me in identifying the issue.
Thanks,
JBabu.
Hi
use this
Integer nd;
Opputunity o1 = new Opputunity();
String str;
try to make public in private wrapOpp(Integer ndx, Opportunity o, String err) { here
OppController.wrapOpp Wrapvar = new OppController.wrapOpp (nd,o1,str);
Regards,
Rajesh.
All Answers
Hi
use this
Integer nd;
Opputunity o1 = new Opputunity();
String str;
try to make public in private wrapOpp(Integer ndx, Opportunity o, String err) { here
OppController.wrapOpp Wrapvar = new OppController.wrapOpp (nd,o1,str);
Regards,
Rajesh.
Thank you Rajesh...
I used the same approach but getting error as
Invalid type: ctrl.wrpsch
Here goes my code:--
public class lisch
{
lisch(ApexPages.StandardController stdControlle){ }
public class wrpsch
{
public OpportunityLineItemSchedule c {get; set;}
public wrpsch(OpportunityLineItemSchedule sc)
{
c = sc;
}
}
Apex Test Class:--
ApexPages.StandardController stdController= new ApexPages.StandardController(o);
lisch ctrl=new lisch(stdController);
OpportunityLineItemSchedule olistest1=new OpportunityLineItemSchedule();
ctrl.wrpsch = new ctrl.wrpsch(olistest1);
apex class "lisch" is an extension class.
Hi
lisch.wrpsch lw = new lisch.wrpsch(olistest1);
Try this it will helps u.
Regards,
Rajesh.
It worked .. :) thank you