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

help for test case
this is the controller i have written and plz help me how to write test case Public class Remarkscontroller { public Appointment__c[] blockedappts {get; set;} String m_param; String y_param; Date Di = system.today(); Public Integer monthc {get;set;} public Integer Year{get; set;} Public string monthname {get;set;} public Remarkscontroller(Dev_Appt_Calendar_Repeat controller) { m_param = System.currentPageReference().getParameters().get('br'); y_param = System.currentPageReference().getParameters().get('dr'); Monthc = di.month(); Year= di.year(); if(Monthc == 12){ monthname = 'December'; } if(Monthc == 11){ monthname = 'November'; } if(Monthc == 10){ monthname = 'October'; } if(Monthc == 9){ monthname = 'September'; } if(Monthc == 8){ monthname = 'August'; } if(Monthc == 7){ monthname = 'July'; } if(Monthc == 6){ monthname = 'June'; } if(Monthc == 5){ monthname = 'May'; } if(Monthc == 4){ monthname = 'April'; } if(Monthc == 3){ monthname = 'March'; } if(Monthc == 2){ monthname = 'Febuary'; } if(Monthc == 1){ monthname = 'January'; } //blockedappts = [select id,appt_date__c,Calander_Day__c,Appt_remarks__c,Block_the_Entire_Day__c from Appointment__c where Block_the_Entire_Day__c=TRUE AND Recordtypeid=:'01290000000YnZw' AND CALENDAR_YEAR(Appt_date__c) =:Year AND CALENDAR_MONTH(Appt_date__c)=:month AND branch__c =: m_param AND Doctor__c=:y_param]; blockedappts = [select id,appt_date__c,Calander_Day__c,Appt_remarks__c,Block_the_Entire_Day__c from Appointment__c where Block_the_Entire_Day__c=TRUE AND Recordtypeid=:'01290000000YnZw' AND CALENDAR_YEAR(Appt_date__c) =:Year AND CALENDAR_MONTH(Appt_date__c)=:Monthc AND branch__c =: m_param AND Doctor__c=:y_param]; } } this is the test case i havew written and the error is saying the constructor is not defined @isTest private class Remarkscontroller_TC { static testmethod void TestController() { Remarkscontroller rc= new Remarkscontroller(); } }
Hi,
I have made few changes(Red Colour) inside your code .
Try the below code:
Public class Remarkscontroller {
public Appointment__c[] blockedappts {get; set;}
String m_param;
String y_param;
Date Di = system.today();
Public Integer monthc {get;set;}
public Integer Year{get; set;}
Public string monthname {get;set;}
public Remarkscontroller(Dev_Appt_Calendar_Repeat controller)
{
}
public Remarkscontroller()
{
m_param = System.currentPageReference().getParameters().get('br');
y_param = System.currentPageReference().getParameters().get('dr');
Monthc = di.month();
Year= di.year();
show();
}
public void show()
{
if(Monthc == 12){
monthname = 'December';
}
if(Monthc == 11){
monthname = 'November';
}
if(Monthc == 10){
monthname = 'October';
}
if(Monthc == 9){
monthname = 'September';
}
if(Monthc == 8){
monthname = 'August';
}
if(Monthc == 7){
monthname = 'July';
}
if(Monthc == 6){
monthname = 'June';
}
if(Monthc == 5){
monthname = 'May';
}
if(Monthc == 4){
monthname = 'April';
}
if(Monthc == 3){
monthname = 'March';
}
if(Monthc == 2){
monthname = 'Febuary';
}
if(Monthc == 1){
monthname = 'January';
}
blockedappts = [select id,appt_date__c,Calander_Day__c,Appt_remarks__c,Block_the_Entire_Day__c from Appointment__c where Block_the_Entire_Day__c=TRUE AND Recordtypeid=:'01290000000YnZw' AND CALENDAR_YEAR(Appt_date__c) =:Year AND CALENDAR_MONTH(Appt_date__c)=:Monthc AND branch__c =: m_param AND Doctor__c=:y_param];
}
static testmethod void TestController()
{
Remarkscontroller rc= new Remarkscontroller();
for(integer i=12; i>0; i--)
{
rc.Monthc++;
rc.show();
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
hi navatar i want a clear solution in this case u r changing my controller i dont want u to change the controller can u give me the test case for the same controller wirth out changing the constructor
srikanth11,
What is this object?
To test your method, you will have to instanciate this object and pass it to your target controller.
-Andy
hi tech man this is a controller not an object
Then you have to invoke that controller to pass it through to your class - or redo your constructor as Navitar has suggested.
can u plz give me the code how to invoke the controller in test case