Product Development in Brisbane

The first test method

When writing a class that will slot into a framework, I often know that I will need it to implement an interface. The quickest way of getting a test writen is to do this:

public void testSaveActionIsAnAbstractAction() throws Exception {
    assertTrue(AbstractAction.class.isAssignableFrom(SaveAction.class));
}

I then don’t need to type any of this…..

public class ISMSaveAction extends AbstractAction{
public void actionPerformed(ActionEvent e) {
throw new NoSuchMethodError();
}
}

and my next test is obvious.

This test is not to replace the tests that actually test real behaviour. It is a nice way to start getting your code writen, and helps keep the flow of red/green/refactor going.

Leave a Reply