
1. The name of the class should indicate that it’s a test—for example, have the class name start with Test.
2. Extend from JUnit’s TestCase class.
3. The instance variables set up in the setUp() method represent the common fixture for the test methods.
4. Prepare a known state for the test by overriding the protected setUp() method.
5. If using Java 5, it’s good to add the @Override annotation to setUp() and tearDown() to avoid typos.
6. Clean up after our test by overriding the protected tearDown() method.
7. All public void methods starting with test are considered test cases by the JUnit 3.8 TestRunner.
8. Test methods can declare any exceptions—JUnit catches them.
9. Can declare any number of helper methods as long as they don’t look like test methods.
10. Extending TestCase gives a bunch of assertion methods such as assertEquals().