Some general testing practices
- Martin Fowler says "Whenever you are tempted to type
something into a print statement or a debugger expression, write it
as a test case instead."
- At first you will have to create a lot of fixtures, but then
you will find you have created all the infrastructure and new tests
become easier to add.
- Try to write tests that you imagine to be useful. Look for the
boundary cases.
- When to add tests:
- During development: while you are designing your class (but
before implementing).
- During debugging: when someone discovers a defect, first write
a test that should succeed if your program is working, then debug
until it succeeds.
- When to run the tests:
- All the time.
- If you find newly introduced errors right away, then you have a
good idea where the error might be.
- Fix errors right away, keep your test suite running.
previous |
start
.... [Slide 12] ....