How should I build test methods for Visualforce Controller Extensions

The following code will test that you are correctly saving the account record in the constructor (which is all your extension does so far):

public static testMethod void testmyExtension() {
    Account a = new Account(name='Tester');
    insert a;
    ApexPages.StandardController sc = new ApexPages.standardController(a);
    myExtension e = new myExtension(sc);
    System.assertEquals(e.acct, a);
}

As you add more functionality to your extension, take a look at Testing Custom Controllers and Controller Extensions.


So to test the basic invocation of your standard controller start by creating a record of the type you want for the standard controller, than create a standard controller type for that object:

@isTest
public static void testStandardControll(){
    // create an account record (not sure if these are all required fields)
    Account account = new Account(Name='Account Name'); 

    // create a new Account standard controller by passing it the account record
    ApexPages.StandardController controller = new ApexPages.StandardController(account);

    // now pass it to the extension
    myExtension stdController = new myExtension(controller);

    system.assert(stdController != null); // controller has successfully been created

    // .. now test your extension methods, checking validity of results and code coverage. 

}

Obviously you need to cover at least 75% of code at a minimum. Setting the bar higher than that is a good practice. In addition, you should write tests that run code with various different Profiles to make sure it works properly as users other than system admins.

Beyond that, for the most part I don't see a lot of value in writing tests that test base Salesforce functionality--for instance, there's not much value in testing that a child record in a Master-Detail relationship always has a parent. Or that an update operation does, in fact, actually update a record. I see more value focusing on writing tests that test the custom functionality that you have created with your code.