up previous next contents index
Next: Unit Testing with JUnit Up: Unit Testing 101 Previous: What should I test?   Contents   Index

How to apply unit testing

So here begins the philosophy of ``working backwards'' ...

Shown below is a very practical algorithm to help you understand how you should apply Unit Testing4.1

  1. Write one test.
  2. Compile the test. It should fail (because you haven't implemented anything yet).
  3. Implement just enough to compile. (Refactor first if necessary.)
  4. Run the test and see it fail.
  5. Implement just enough to make the test pass.
  6. Run the test and see it pass.
  7. Refactor for clarity and "once and only once".
  8. Repeat from the top.


up previous next contents index
Next: Unit Testing with JUnit Up: Unit Testing 101 Previous: What should I test?   Contents   Index