+ Start a Discussion
Lavanya Ponniah 3Lavanya Ponniah 3 

How to write test class for the below code?

public class ClientProfile 
{
    public Boolean bool {get;set;}
    public Boolean bool1 {get;set;}
     private final  Client_Profile__c order;
     public Client_Profile__c getorder()
     {
         return order;
     }
     public ClientProfile(ApexPages.StandardController stdController) 
     {
        order = (Client_Profile__c)stdController.getRecord();
           
           
     }
     public PageReference next() 
     {
                
       PageReference np = new PageReference('/apex/ClientProfile1');
        np.setRedirect(false);
         return np;                 
    }
    public PageReference Continue1() 
     {
       PageReference np1 = new PageReference('/apex/ClientProfile2');
       np1.setRedirect(false);
       return np1;   
    }
     public PageReference Continue2() 
     {
     
      
       PageReference np2 = new PageReference('/apex/ClientProfile3');
        np2.setRedirect(false);
        return np2;   
    }
    public PageReference back() 
     {
       PageReference np3 = new PageReference('/apex/ClientProfile');
       np3.setRedirect(false);
       return np3;   
    }
     public PageReference back2() 
     {
       PageReference np4 = new PageReference('/apex/ClientProfile1');
       np4.setRedirect(false);
       return np4;   
    }
     public PageReference back3() 
     {
       PageReference np5 = new PageReference('/apex/ClientProfile2');
       np5.setRedirect(false);
       return np5;   
    }
    public PageReference save() 
    {
        insert order;
        PageReference np6 = new PageReference('/apex/Thankuform');
        np6.setRedirect(true);
        return np6;
    }
  /* public List<SelectOption> getTypes()
    {
       Schema.sObjectType sobject_type = Client_Profile__c.getSObjectType();
       Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
       Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();          
       List<Schema.PicklistEntry> pick_list_values = field_map.get('Type_of_Company__c').getDescribe().getPickListValues();
       List<selectOption> options = new List<selectOption>();
       for (Schema.PicklistEntry a : pick_list_values) 
       {
          options.add(new selectOption(a.getLabel(), a.getValue()));
       }
      return options;
   }*/
}
Sri549Sri549
Hello Lavanya,
Please use this and tel me whether it solves your problem or not.

@IsTest
Public Class Test_ClientProfile
{
  Public static void testmethod ClientProfile()
  {
    ClientProfile cp = new ClientProfile();
    cp.next();
    cp.Continue1();
    cp.Continue2();
    cp.back();
    cp.back2();
    cp.back3();
    cp.save();  
  }    


If this solves your problem Please mark as Best Answer.

Regards
Srinivas