Skip to main content
Hello, 

I am trying to deploy a class that will allow me to group my StageName= Qualified opportunities by a custom field called vertical__c.

However, I am running into a code coverage error when trying to deploy this, as the new class is bringing my code coverage down to 73% and I admitadlly do not know near enough about test methods to bring this up.  Can anyone help?

Here is my class: 

 

public with sharing class QualOpController

{

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

public list<String> campaigns {get;set;}

public void load()

{

campaigns= new List<String>();

Opty = [Select id, name, Company_Name__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];

Set<String> campaignSet = new Set<String>();

for (Opportunity j : Opty)

campaignSet.add(j.Vertical__c);

for (String campaign : campaignSet)

{

campaigns.add(campaign);

}

campaigns.sort();

}

}

and here is the test class that I have for it... please don't laugh: 

 

@isTest(seeAllData = false)

public class QualOpControllerTest{

// Unit test Method

static testmethod void UnitTest() {

//Create your opportunity record with required field

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

//insert j;

test.startTest();

QualOpControllerTest qo = new QualOpControllerTest();

test.stopTest();

}

}

What is the best way for me to sure up this test?

Thanks in advance!

John
5 respostas
  1. 6 de abr. de 2016, 19:59
    Sorry it should be 

    test.startTest();

    QualOpController qo = new QualOpController();

    qo.load();

    test.stopTest();

    Try above.
0/9000