I would like to know the best way to write test methods for controller extension classes that are used by Visualforce.
What is the minimum set code that I need to cover the basic operation of the controller without taking into account any custom functionality that I might add.
Here is my example class with the test method ready to be completed.
public with sharing class myExtension{
private final Account acct;
public myExtension(ApexPages.StandardController stdController){
this.acct = (Account)stdController.getRecord();
}
public static testMethod void testmyExtension(){
}
}
Best Answer
The following code will test that you are correctly saving the account record in the constructor (which is all your extension does so far):
As you add more functionality to your extension, take a look at Testing Custom Controllers and Controller Extensions.