up previous next contents index
Next: An example Up: Working Backwards with JUnit Previous: How you should apply   Contents   Index

How to do Unit Testing with JUnit

  1. Build a subclass of the class TestCase.
  2. Create as many test methods in this test class as necessary. 
  3. With JUnit, if each method begins with the name "test", like testThis(), testThat(), etc., the test methods will be discovered automatically.
  4. The testing framework collects up all the tests and executes them one after another.
  5. You can create a method named setUp() that sets stuff up before each test is run.
  6. You can create a method named tearDown() that helps you get rid of stuff after each test is run.


up previous next contents index
Next: An example Up: Working Backwards with JUnit Previous: How you should apply   Contents   Index