+ Start a Discussion
arun kumar 577arun kumar 577 

hi guys, i need urgent test class for this. immeadiately

public class ViewDocument{   
    public  customer__c cust{get;set;}    
    public string recId{get;set;}

    public ViewDocument(ApexPages.StandardController ctrl){
        recId=ApexPages.currentPage().getParameters().get('Id');              
         cust=[SELECT id, Viewed_Status__c, Viewed_On__c FROM customer__cWHERE Id=:recId];
    }
    
    public pageReference countClicks(){
    
       pagereference pr=new pagereference('/'+cust.Id);
        return pr;
       
    }     
}

please
PulaK_PrabhakaRPulaK_PrabhakaR
@isTest
public class Test_ViewDocument {
    @isTest()
    static void ViewDocument_unitTest(){
        
        // Creating "customer__c" dummy data
        customer__c cust = new customer__c(Viewed_Status__c = 'test',Viewed_On__c = System.Today());
        insert cust;
    
        apexPages.Currentpage().getParameters().put('Id',cust.Id);  
        
        ApexPages.StandardController con = new ApexPages.StandardController(cust);
        ViewDocument vDoc = new ViewDocument(con);
        vDoc.countClicks(); 
    }
}


Give any value for "Viewed_Status__c" if it is restricted picklist. Also, create data of any required field of "customer__c" object.

Please mark the answer as best answer if the information is informative. So that question is removed from an unanswered question and appear as a proper solution.