You need to sign in to do that
Don't have an account?
John Neff
Error: Variable does not exist but it DOES exist!
Hello,
I am trying to write a test class for a VF controller, and I am getting an error saying the variable does not exist even though it does! Why would this be happening?
Here is my controller:
And here is my test:
I keep getting this error:
Can anyone help? I'm really stuck here
I am trying to write a test class for a VF controller, and I am getting an error saying the variable does not exist even though it does! Why would this be happening?
Here is my controller:
public class DailySalesReportController{ public List<Opportunity> listOfCefOpToday {get;set;} public List<Opportunity> listOfLoganOpToday {get;set;} public List<Lead> listOfCefLdToday {get;set;} public List<Lead> listOfLoganLdToday {get;set;} public List<Sales_Meetings__c> listOfCefSkedToday {get;set;} public List<Sales_Meetings__c> listOfLoganSkedToday {get;set;} public List<Sales_Meetings__c> listOfCefOcToday {get;set;} public List<Sales_Meetings__c> listOfLoganOcToday {get;set;} public Opportunity CefOpToday {get;set;} public Opportunity LoganOpToday {get;set;} public Lead CefLdToday {get;set;} public Lead LoganLdToday {get;set;} public Sales_Meetings__c CefSkedToday {get;set;} public Sales_Meetings__c LoganSkedToday {get;set;} public Sales_Meetings__c CefOcToday {get;set;} public Sales_Meetings__c LoganOcToday {get;set;} public DailySalesReportController(){ listOfCefOpToday = [Select id, name from Opportunity WHERE Created_Today__c = TRUE AND Owner_Name__c = 'Jeff Cefalu']; listOfLoganOpToday = [Select id, name from Opportunity WHERE Created_Today__c = TRUE AND Owner_Name__c = 'Logan Connolly']; listOfCefLdToday = [Select id, name from Lead WHERE Created_Today__c = TRUE AND Owner_Name__c = 'Jeff Cefalu']; listOfLoganLdToday = [Select id, name from Lead WHERE Created_Today__c = TRUE AND Owner_Name__c = 'Logan Connolly']; listOfCefSkedToday = [Select id, name from Sales_Meetings__c WHERE Created_Today__c = TRUE AND Owner_Name__c = 'Jeff Cefalu']; listOfLoganSkedToday = [Select id, name from Sales_Meetings__c WHERE Created_Today__c = TRUE AND Owner_Name__c = 'Logan Connolly']; listOfCefOcToday = [Select id, name from Sales_Meetings__c WHERE Occurred_Today__c = TRUE AND Owner_Name__c = 'Jeff Cefalu']; listOfLoganOcToday = [Select id, name from Sales_Meetings__c WHERE Occurred_Today__c = TRUE AND Owner_Name__c = 'Logan Connolly']; } }
And here is my test:
@isTest(seeAllData = true) public class DailySalesReportControllerTest{ // Unit test Method static testmethod void UnitTest() { //Create your Opportunity record with required field //Opportunity b = new Opportunity(Created_Today__c = TRUE); //insert b; test.startTest(); DailySalesReportControllerTest ub = new DailySalesReportControllerTest(); if(ub.listOfCefOpToday!=null && !ub.listOfCefOpToday.isEmpty()) Opportunity cefOpportunity = ub.listOfCefOpToday.get(0); if(ub.CefOpToday !=null) String CefOpTodayId = ub.CefOpToday.Id; test.stopTest(); } }
I keep getting this error:
Error: Compile Error: Variable does not exist: listofcefoptoday at line 12 column 41
Can anyone help? I'm really stuck here
@isTest(seeAllData = true)
public class DailySalesReportControllerTest {
// Unit test Method
static testmethod void UnitTest() {
//Create your Opportunity record with required field
//Opportunity b = new Opportunity(Created_Today__c = TRUE);
//insert b;
test.startTest();
//DailySalesReportControllerTest ub = new DailySalesReportControllerTest();
DailySalesReportController ub = new DailySalesReportController();
if (ub.listOfCefOpToday != null && !ub.listOfCefOpToday.isEmpty())
Opportunity cefOpportunity = ub.listOfCefOpToday[0];
if (ub.CefOpToday != null)
String CefOpTodayId = ub.CefOpToday.Id;
test.stopTest();
}
}
Regards,
Pawan Kumar
All Answers
Let us know if this will help you
Here is the error:
@isTest(seeAllData = true)
public class DailySalesReportControllerTest {
// Unit test Method
static testmethod void UnitTest() {
//Create your Opportunity record with required field
//Opportunity b = new Opportunity(Created_Today__c = TRUE);
//insert b;
test.startTest();
//DailySalesReportControllerTest ub = new DailySalesReportControllerTest();
DailySalesReportController ub = new DailySalesReportController();
if (ub.listOfCefOpToday != null && !ub.listOfCefOpToday.isEmpty())
Opportunity cefOpportunity = ub.listOfCefOpToday[0];
if (ub.CefOpToday != null)
String CefOpTodayId = ub.CefOpToday.Id;
test.stopTest();
}
}
Regards,
Pawan Kumar