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
miku1051miku1051 

test class help..????

public with sharing class createmassleadcntr {
public Lead ld{get;set;}
public Lead ld1{get;set;}
public list<Lead> listld=new list<lead> ();
public boolean perinfo{get;set;}
public boolean sav{get;set;}
    public createmassleadcntr(ApexPages.StandardController controller)
    {
        perinfo=false;
        ld=new Lead();
        ld1=new Lead();
        sav=false;
    }

public void add()
{
        sav=true;
        system.debug('------'+ld);
        if(ld.lastname==null)
        {
            perinfo=true;
        }
 
        else
        {
          
            ld.Company=ld1.Company;
            ld.Phone=ld1.Phone;
            ld.street=ld1.street;
            ld.LeadSource=ld1.LeadSource;
            listld.add(ld);
            ld=new Lead();
            
        }
       
}
public void save()
{
    sav=false;
    if(ld.lastname!=null && ld.Company!=null)
    {
        ld.Company=ld1.Company;
        ld.Phone=ld1.Phone;
        ld.street=ld1.street;
        ld.LeadSource=ld1.LeadSource;
        listld.add(ld);
    }
        upsert listld;
        ld=new Lead();
        ld1=new Lead();
        perinfo=false;
}

 Please help me the test class....???

Rajesh SriramuluRajesh Sriramulu

Hi

 

try this

 

@isTest

private class createmassleadcntr_test{

public static testmethod void createmassleadcntr_test()

{

Lead ld = new Lead();

ld.lastname='tet';

here insert the mandatory fields

insert ld;

ApexPages.StandardController sc = new ApexPages.StandardController(ld);

createmassleadcntr crm= new createmassleadcntr(sc);

here insert lead which lastname to ne null

crm.add();

herer update lead according to if condition

crm.save();

 

}}

 

Regards,

Rajesh.