up previous next contents index
Next: A sample JUnit session Up: Unit Testing with JUnit Previous: Unit Testing with JUnit   Contents   Index


How to create unit tests 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: A sample JUnit session Up: Unit Testing with JUnit Previous: Unit Testing with JUnit   Contents   Index