This was my favorite technique until I found
JUnit. I wrote a lot of things where I ran main and visually inspect a lot of displays. One advantage to this is the tests are always available any time the class is available.
JUnit moves the tests into seperate classes which has pros & cons. The JUnit framework encourages you to check test results programatically instead of visually. And you can aggregate a bunch of tests into a regression suite that is easy to run over and over.
If you haven't met JUnit yet, see
http://www.JUnit.org. The Getting Started link has another link to Test Infected which is a good (maybe overly detailed) intro to unit testing.