You need to sign in to do that
Don't have an account?
Thedude
New Developer looking for help in test cases.
I am new to the apex coding. How would i be able to creat a test case for this code.
global static Map<ID, Prospect__c> GetBulkFullProspect(List<ID> prospectIDs)
{
// Ask the database for ALL the prospect fields.
string queryString = URLUtilities.GetFullBaseQuery('i360__Prospect__c');
queryString += ' WHERE ID IN :ProspectIDs ';
List<Prospect__c> FullProspects = (List<Prospect__c>)(database.query(queryString));
Map<Id,Prospect__c> retMap = new Map<ID,Prospect__c>();
for(Prospect__c prospect : FullProspects)
retMap.put(prospect.id,prospect);
return retMap;
GetBulkFullProspect returns a Map and takes a List as its single argument. So this line won't compile, because it's assuming a return value of type Prospect__c and an argument of type 'Id':
You probably need something more like this:
All Answers
A test case is there to check that the code is doing what it is supposed to do.
Can you explain what the code you have written is supposed to do? If you ran it, what would it mean to say that it had worked or that it had not worked?
there is a similar test case that goes as follows:
global static Prospect__c GetFullProspect(ID proID)
{
string BasicQuery = URLUtilities.GetFullBaseQuery('i360__Prospect__c') + ' WHERE ID = :proID ';
List<Prospect__c> FullProspect = (List<Prospect__c>)(database.query(BasicQuery));
if(FullProspect.size() == 0)
return null;
else
return FullProspect[0];
and the test case to follow this is:
static testMethod void testGetFullProspect()
{
Prospect__c OldProsp = TestUtilities.CreateProspect(true);
Prospect__c NewProsp = ProspectUtilities.GetFullProspect(OldProsp.ID);
TestUtilities.AssertProspect(OldProsp, NewProsp);
}.
For what i originally wrote, the test case that I wrote is:
static testMethod void testGetBulkFullProspect()
{
Prospect__c OldProsp2= testUtilities.CreateProspect (true);
Prospect__c NewProsp2= ProspectUtilities.GetBulkFullProspect(OldProsp2.ID);
TestUtilities.AssertProspect(OldProsp2, NewProsp2);
}.
hope the helps you help me
GetBulkFullProspect returns a Map and takes a List as its single argument. So this line won't compile, because it's assuming a return value of type Prospect__c and an argument of type 'Id':
You probably need something more like this: