+ Start a Discussion
SFDC Coder 8SFDC Coder 8 

Test class for controller class in command button

Hi All,
I am new to salesforce.
I have created a custom button in visualforce page to change status field.
I have written visualforce page and controller class for the same.
I want to write test class for the same class.

Here is my code
 
public with sharing class changeStstus {

    Public id lid;
     Public Order lRec;
     Public string strRs{get;set;}  
     public string strSt{get;set;}
    
    public changeStstus(ApexPages.StandardController controller) {
        
        if(ApexPages.currentPage().getParameters().get('id') != null) {      
              lid= ApexPages.currentPage().getParameters().get('id');
            getRecord(lid);     
        }
      }
    
    public void getRecord(ID lid){
       lRec = [select id,F1__c,status from Order where id =:lid];
       strRs = lRec.F1__c;
       strSt='Saved';
      }
    
    public PageReference  Save(){
        lRec.F1__c = strRs;
        lRec.status= strSt;
        lRec lRec;  
        PageReference ReturnPage = new PageReference('/' + lRec.id); 
        ReturnPage.setRedirect(true); 
        return ReturnPage;
    }
   
    public PageReference  Cancel(){
        PageReference ReturnPage = new PageReference('/' + lRec.id); 
        ReturnPage.setRedirect(true); 
        return ReturnPage;  
    }

}

Please help me

Thanks in Advance