You need to sign in to do that
Don't have an account?
John Neff
Test class isn't quite good enough - how do I beef it up?
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:
and here is the test class that I have for it... please don't laugh:
What is the best way for me to sure up this test?
Thanks in advance!
John
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
test.startTest();
QualOpController qo = new QualOpController();
qo.load();
test.stopTest();
Try above.
All Answers
QualOpControllerTest qo = new QualOpControllerTest();
qo.load();
test.stopTest();
Try above.
and recieved the error:
Error: Compile Error: Method does not exist or incorrect signature: [QualOpControllerTest].load() at line 8 column 1
It seems I've misunderstood the syntax here
but now I am getting the error:
Error: Compile Error: Method does not exist or incorrect signature: [QualOpControllerTest].load() at line 10 column 1
it doesn't seem to like the qu.load(); element
test.startTest();
QualOpController qo = new QualOpController();
qo.load();
test.stopTest();
Try above.
Thank you so much!