function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ThedudeThedude 

New Developer looking for help in test cases.

I need to create a test case for this code:

 

global class LeadConvertResult
{
global ID ProspectId {get;set;}
global boolean Success {get;set;}
global Integer Strength {get;set;}

global LeadConvertResult()
{
Success = false;
Strength = 0;
}

 

How would I go about doing this?

     

Alok_NagarroAlok_Nagarro

Hi,

 

Purpose of writing test Method for apex is to insure the execution of your code is expected or not.

For your class test method would be as given below -

 

static testMethod void mySampleTest()
{
 LeadConvertResult l=new LeadConvertResult();
}

 

Since you didnt write any method in your class so just create instance of that class so constructor will execute automatically.

craigmhcraigmh

Yeah, and make sure you reference the properties. Success and strength are tested in the constructor, but you also need to reference ProspectId.

 

static testMethod void mySampleTest()
{
	Test.startTest();
	LeadConvertResult l=new LeadConvertResult();
	l.ProspectId = (an account Id or something like that);
	Test.stopTest();
}