Salesforce Controller for VF页面的代码覆盖率帮助?

时间:2017-08-11 17:11:47

标签: salesforce apex-code visualforce

我有一个显示0%代码覆盖率的控制器,但我不确定为什么我的测试类不能覆盖任何东西。有人可以帮忙吗?

这是我的控制器:



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];
   


}
}
&#13;
&#13;
&#13;

这是我的测试类:

&#13;
&#13;
@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();
    }   
}
&#13;
&#13;
&#13;

有人愿意帮我加油吗?

这对我来说意味着世界。

提前谢谢!!!!!!

约翰

1 个答案:

答案 0 :(得分:0)

您的代码中有几个最佳实践。但是,如果不知道这个用途是什么,很难为您提供修复。

如上所述,您的测试类应该提供66%的控制器覆盖率,而不是0%。所有触发器和类都需要平均75%。您需要为控制器中的10个Buyer__c变量提供保险。

另外,请务必使用Controller部署生产Test Class。