They effectively communicate in an executable
format how to use the software. They also prevent tendencies to
over-build the system based on speculation. When all the tests
pass, you know you're done!
Test-driven development is a lot more fun than writing tests
after the code seems to be working
Do I have to write a test for
everything?
No, just test everything that could reasonably break.
If something is difficult to test, it's usually an opportunity
for a design improvement.
Frequent testing gives you confidence that your
changes didn't break anything and generally lowers the stress of
programming in the dark.
Run all your unit tests as often as possible, ideally every time
the code is changed
For larger systems, you may just run specific test suites that
are relevant to the code you're working on.
write a failing test that
exposes the defect. When the test passes, you know the defect
is fixed!
Don't forget to use this as a learning opportunity. Perhaps the
defect could have been prevented by being more aggressive about
testing everything that could reasonably break.
Future for HealthKit is great if Apple can pull it off. Letting different apps and devices talk to each other essentially makes your iPhone center of your lifestyle.