You Are Number 6 links to this (his) article Agile Bug Finding with Risk Targeted Testing in Java, which lays out some best pratices in testing:
- Run the tests every time you change something. If you use Ant then have a test task that gets triggered on change. Keep your old test results for reference.
- Use XML for your test data. Hard coded tests are more difficult to maintain. An XML database is the ultimate form, but using a simple tool like XStream can do what you need. Use the XML include directive to share data between sets of test cases.
- Check your test classes with FindBugs. FindBugs will examine the logic, which should be very simple in test classes. Having passed that your test classes can be safely used.
- Use MockObjects or real classes with Proxy interceptors to keep the unit tests at the unit level. This insulates test classes, test data and test running against changes to other parts of the system.
- The test class hierarchy should mimic that of the real code under test, this allows abstract classes to be tested properly.
- For reviewing code use an integrated tool like Jupiter for Eclipse, that stores the review information with the source code.
- Build metrics collection into your test process. Use the extensions to Checkstyle to get some and test to get the others. For example try running a complex test case 1000 times to get an idea of performance, or at the end of the test serialize the object under test and see its size. You can then watch for dramatic changes in metrics.
- Use architectural checks like Macker rules to preserve the architecture standards.
- Use a tool like vDoclet to generate an initial set of test cases and your basic JUnit test class from the interface definition.