+ Start a Discussion
aressaress 

need test class for following

can anyone provide test cases for following scenario..consider all positive negative test cases.\

public class LeadRecord {
/**
This method displays total number of distinct Lead records on basis of 'Lead Source'
having greater than 10 leads.
@return Nothing.
*/
public static void displayLeads() {
List<AggregateResult> leadList = [
SELECT
LeadSource ls,
count_distinct(id) cnt
FROM
Lead
GROUP BY
LeadSource
HAVING
count_distinct(id) > 10
];
for(AggregateResult leadRecord : leadList) {
System.debug(leadRecord.get('ls') + ' -- ' + leadRecord.get('cnt'));
}
}
}
Akshay_DhimanAkshay_Dhiman
Hi Ayisha,
 
@isTest
private class Test_LeadRecored {
    private static testMethod void runTests(){
        test.startTest();
        Lead lead = new Lead();
        lead.FirstName = 'Trigger1';
        lead.LastName = 'Test1';
        lead.Company = 'Trigger Test1';
        lead.LeadSource = 'Sales2.0';
        LeadRecord.displayLeads();
        test.stopTest();
        
    }
}

Hope it will help you 

Thanks 
Akshay