Skip to main content
Hello, 

I have a controller which includes serveral UPDATE statements - however I am running into a code coverage error and I think it is because my UPDATE is not covered in my test class.  I tried to add it but I ran into an error.  What is the best way for me to beef up the test class for the controller below?  Thanks in advance!

 

CLASS:

public class R2MPipeLineController{

public List<Opportunity> listOfLive {get; set;}

public List<Opportunity> listOfViability {get; set;}

public List<Opportunity> listOfLaunchPad {get; set;}

public List<Opportunity> listOfContractSent {get; set;}

public List<Opportunity> listOfQualified {get; set;}

public Opportunity Live {get; set;}

public Opportunity Viability {get; set;}

public Opportunity LaunchPad {get; set;}

public Opportunity ContractSent {get; set;}

public Opportunity Qualified {get; set;}

public PageReference saveCS(){

UPDATE listOfContractSent;

return null;

}

public PageReference saveVI(){

UPDATE listOfViability;

return null;

}

public PageReference saveLP(){

UPDATE listOfLaunchPad;

return null;

}

public PageReference saveQD(){

UPDATE listOfQualified;

return null;

}

public String getName(){

return 'R2MPipeLineController';

}

public R2MPipeLineController() {

listofLive = [Select id, name, CreatedDate, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE StageName = 'Live' ORDER BY Weeks_Live__c DESC];

listOfViability = [Select id, name, Amount, Projected_Revenue__c, CreatedDate, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE StageName = 'Viability' ORDER BY Days_Since_Last_Modified__c DESC];

listOfLaunchPad = [Select id, name, Amount, Projected_Revenue__c, CreatedDate, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE StageName = 'Launch Pad' ORDER BY Days_Since_Last_Modified__c DESC];

listOfContractSent = [Select id, name, Amount, Projected_Revenue__c, CreatedDate, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c, Contract_Age__c from Opportunity WHERE StageName = 'Contract Sent' ORDER BY Contract_Age__c ASC];

listOfQualified = [Select id, name, Amount, Projected_Revenue__c, CreatedDate, Company_Name__c, Next_Step__c, Vertical__c, Weeks_Live__c, Days_Since_Last_Modified__c, Contract_SENT__c, NextStep, LeadSource, Probability, Spend_Last_Week__c, Spend_Last_30_Days__c, Owner_Name__c, Revenue_All_Time__c from Opportunity WHERE StageName = 'Qualified' ORDER BY Probability DESC];

}

}

And here is my test class: 

 

@isTest(seeAllData = false)

public class R2MPipeLineControllerTest{

// Unit test Method

static testmethod void UnitTest() {

//Create your buyer record with required field

//Opportunity o = new Opportunity(StageName = 'Qualified');

//insert o;

test.startTest();

R2MPipeLineController qo = new R2MPipeLineController();

test.stopTest();

}

}

 
2 respostas
  1. 10 de mai. de 2016, 07:59
    Hi John

      Try this code

      

    @isTest(seeAllData = false)

    public class R2MPipeLineControllerTest{

    // Unit test Method

    static testmethod void UnitTest() {

    //Create your buyer record with required field

    //Opportunity o = new Opportunity(StageName = 'Qualified');

    //insert o;

    test.startTest();

    R2MPipeLineController r2mpl = new R2MPipeLineController();

    r2mpl.saveCS();

    r2mpl.saveVI();

    r2mpl.saveLP();

    r2mpl.saveQD();

    r2mpl.getName();

    test.stopTest();

    }

    }

     
0/9000