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

How can code coverage on a class be 0% when the test is passing when run?
Hello,
I have an apex class that functions as a VF page controller, and when I run the associated test class it passes - but when I look at the class the coverage is at 0% and it is bringing my code coverage down below 75%. How can this be? I would really appreciate some help here!
Here is my controller:
and here is my test class:
I ill be eternally grateful if someone can help me solve this!
Thank you,
John
I have an apex class that functions as a VF page controller, and when I run the associated test class it passes - but when I look at the class the coverage is at 0% and it is bringing my code coverage down below 75%. How can this be? I would really appreciate some help here!
Here is my controller:
public class R2MBizBookController{ public List<Buyer__c> listOfDeck {get; set;} public List<Buyer__c> listOfNewThirty {get; set;} public List<Buyer__c> listOfNewTW {get; set;} public List<Buyer__c> listOfLegacy {get; set;} public List<Buyer__c> listOfTQ {get; set;} public List<Buyer__c> listOfAQ {get; set;} public List<Buyer__c> listOfBQ {get; set;} public List<Buyer__c> listOfCQ {get; set;} public List<Buyer__c> listOfDQ {get; set;} public List<Buyer__c> listOfEQ {get; set;} public Buyer__c Live {get; set;} public Buyer__c NewTW {get; set;} public Buyer__c Viability {get; set;} public Buyer__c LaunchPad {get; set;} public Buyer__c TQ {get; set;} public Buyer__c AQ {get; set;} public Buyer__c BQ {get; set;} public Buyer__c CQ {get; set;} public Buyer__c DQ {get; set;} public Buyer__c EQ {get; set;} public R2MBizBookController() { listofDeck = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Commitment_c__c from Buyer__c WHERE Pipeline_Status__c = 'OnDeck' ORDER BY Name ASC]; listofNewThirty = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE Pipeline_Status__c = 'New 30' ORDER BY Sales_Origination_Date__c DESC]; listofNewTW = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE New_Live__c = TRUE ORDER BY Sales_Origination_Date__c DESC]; listofLegacy = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE Pipeline_Status__c = 'Legacy' ORDER BY Sales_Origination_Date__c DESC]; listofTQ = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE TQ_Pipeline__c = TRUE ORDER BY Sales_Origination_Date__c DESC]; listofAQ = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE Pipeline_Status__c = 'AQ' ORDER BY Sales_Origination_Date__c DESC]; listofBQ = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE Pipeline_Status__c = 'BQ' ORDER BY Sales_Origination_Date__c DESC]; listofCQ = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE Pipeline_Status__c = 'CQ' ORDER BY Sales_Origination_Date__c DESC]; listofDQ = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE Pipeline_Status__c = 'DQ' ORDER BY Sales_Origination_Date__c DESC]; listofEQ = [Select id, name, Sales_Lead_Source__c, Routing_Status__c, Client_Status__c, Total_Re_Orders__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_LN__c, Sales_Origination_Date__c from Buyer__c WHERE Pipeline_Status__c = 'EQ' ORDER BY Sales_Origination_Date__c DESC]; } }
and here is my test class:
@isTest(seeAllData = true) public class R2MBizBookControllerTest{ // Unit test Method static testmethod void UnitTest() { //Create your buyer record with required field //Buyer__c b = new Buyer__c(Pipeline_Status__c = 'Legacy'); //insert b; test.startTest(); R2MBizBookController ub = new R2MBizBookController(); test.stopTest(); } }
I ill be eternally grateful if someone can help me solve this!
Thank you,
John
@isTest(seeAllData = false)
public class R2MBizBookControllerTest{
// Unit test Method
static testmethod void UnitTest() {
//Create your buyer record with required field
//Buyer__c b = new Buyer__c(Pipeline_Status__c = 'Legacy');
//insert b;
test.startTest();
R2MBizBookController ub = new R2MBizBookController();
if(ub.listOfDeck!=null && !ub.listOfDeck.isEmpty())
Buyer__c deckBuyer = ub.listOfDeck.get(0);
// If above two line repeat for all list property from listOfNewThirty to listOfEQ
if(ub.Live !=null)
String LiveId = ub.Live.Id;
// Repeat above for other property from NewTW to EQ
test.stopTest();
}
}
All Answers
Please try below one and let me know if it works.
@isTest(seeAllData = false)
public class R2MBizBookControllerTest{
// Unit test Method
static testmethod void UnitTest() {
//Create your buyer record with required field
//Buyer__c b = new Buyer__c(Pipeline_Status__c = 'Legacy');
//insert b;
test.startTest();
R2MBizBookController ub = new R2MBizBookController();
if(listOfDeck!=null && !listOfDeck.isEmpty())
Buyer__c deckBuyer = listOfDeck.get(0);
// If above two line repeat for all list property from listOfNewThirty to listOfEQ
if(Live !=null)
String LiveId = Live.Id;
// Repeat above for other property from NewTW to EQ
test.stopTest();
}
}
I am getting the error: Error: Compile Error: Variable does not exist: listOfDeck at line 11 column 15
when trying to compile however
@isTest(seeAllData = false)
public class R2MBizBookControllerTest{
// Unit test Method
static testmethod void UnitTest() {
//Create your buyer record with required field
//Buyer__c b = new Buyer__c(Pipeline_Status__c = 'Legacy');
//insert b;
test.startTest();
R2MBizBookController ub = new R2MBizBookController();
if(ub.listOfDeck!=null && !ub.listOfDeck.isEmpty())
Buyer__c deckBuyer = ub.listOfDeck.get(0);
// If above two line repeat for all list property from listOfNewThirty to listOfEQ
if(ub.Live !=null)
String LiveId = ub.Live.Id;
// Repeat above for other property from NewTW to EQ
test.stopTest();
}
}
Gret to know. Please give me a favour by marking best answer. Thanks.