alix-o
6/26/2013 - 1:19 AM

Method for testing a visualforce extension and controller methods.

Method for testing a visualforce extension and controller methods.

@isTest
//class name
private class vacationdaysTEST{
//test method
private static testMethod void vacationdaysTEST(){
    //instantiate the object on which the extension is defined.
    Leave_Request__c lr  = new Leave_Request__c();
    //instantiate standardcontroller, pass object variable into constructor
    ApexPages.StandardController sc = new ApexPages.StandardController(lr);
    //instantiate extension controller, pass standard controller variable into constructor
    vacationdays controller = new vacationdays(sc);
        //executes method within the controller extension
        controller.getUserInfo();
}
}