A Practical Guide To Unit Testing: Test Driven Development
A Practical Guide To Unit Testing: Test Driven Development
A Practical Guide To Unit Testing: Test Driven Development
Testing
Nope…
We have enough tests when we feel
CONFIDENT in our code quality.
If we don‟t feel confident that our code works
and it‟s safe to refactor, keep writing tests…
Unit tests are code. They need to be maintained.
They cost time to write and they cost more time to
maintain.
Beware of writing tests for their own sake.
Trying to hit 100% code coverage is usually not
necessary (but it is a usual byproduct of TDD).
Don‟t duplicate testing. Test only what hasn‟t yet
been covered.
Don‟t trust UTs that are not well written.
Don‟t write complex tests. Keep them simple.
“Changing existing code to refine its structure without
changing its behavior.”
MAKE ONLY SMALL CHANGES AT ONE TIME.
Then test them. With ALL the tests.
Then review them with someone. Then check them in…
This should happen a LOT.
Consider the whole design – not just the classes and methods
you happen to be touching.
Think globally, act locally…
Look at the overall design and make refactoring changes
accordingly.
Refactor MERCILESSLY.
Code quality should not be negotiable.
It‟s implied that our code should just work.
UT‟s and other tests in our test suite help us to
know quickly if our code really does what we
intended.
UT‟s help us know in a few seconds whether a
change we make has impact on the code and
might affect quality.
There are always bugs.
If there is a bug, it means someplace we forgot
a test! [do we have good acceptance criteria?]