As my dependance on this technique has grown, my code coverage % has declined despite the fact that I am writing a test class for each new class created. This leads me to believe that my test class is not sufficiently covering the class - but I do not know how to make it more efficient. Here is a corresponding example test class:public with sharing class CloseQTRController
{
public List <Buyer__c> Buyer {get;set;}
public list<String> salesqtr {get;set;}
public void load()
{
salesqtr= new List<String>();
Buyer = [Select id, name, Routing_Status__c, Sales_Quarter__c, Funds_Collected_All_Time__c, Sales_Origination_Date__c, Sales_LN__c from Buyer__c WHERE Current_FQ_Buyer__c = FALSE ORDER BY Sales_Origination_Date__c ASC];
Set<String> salesqtrSet = new Set<String>();
for (Buyer__c j : Buyer)
salesqtrSet.add(j.Sales_Quarter__c);
for (String salesqtr : salesqtrSet)
{
salesqtrs.add(salesqtr);
}
salesqtrs.sort();
}
What should I add to this test class to bring up my code coverage? I have not added any new classes without corresponding test classes, so I am sure it is the set of classes that use the format above that is dragging my code coverage down. Can anyone help!?Thanks in advance!John@isTest(seeAllData = false)
public class CloseQTRControllerTest{
// Unit test Method
static testmethod void UnitTest() {
//Create your buyer__c record with required field
//Buyer__c b = new Buyer(Current_FQ_Buyer__c = TRUE);
//insert b;
test.startTest();
CloseQTRControllerTest qt = new CloseQTRControllerTest();
test.stopTest();
}
}
This is a duplicate ticket. Your issue is resolved on below post1) https://developer.salesforce.com/forums/ForumsMain?id=906F0000000Bb3zIAC @isTest
public class CloseQTRControllerTest
{
static testmethod void UnitTest()
{
Buyer__c b = new Buyer();
b.Current_FQ_Buyer__c = FALSE ;
// add all required field here
insert b;
test.startTest();
CloseQTRControllerTest qt = new CloseQTRControllerTest();
test.stopTest();
}
}
Let us know if you need more help
ThanksAmit Chaudhary