Index
Day 8 - Unit tests
-
The tests and the production code are written together
-
If we work this way, those tests will cover virtually all of our production code
The three laws of TDD (test driven development)
-
You may not write production code until you have written a failing unit test
-
You may not write more of a unit test than is sufficient to fail, and not compiling is failing
-
You may not write more production code than is sufficient to pass the currently failing test
Keeping the tests clean
-
Having dirty tests is equivalent to having no tests
A dual standard
-
Test code must be simple, succinct and expressive, but it doesn’t need to be as efficient as production code. After all, it runs in a test environment
Single concept per test
F.I.R.S.T. (rules for clean tests)
-
Fast: tests should be fast
-
Independent: test should not depend on each other
-
Repeatable: test should be repeatable in every environment
-
Self-validating: tests should have a boolean output
-
Timely: tests should be written just before the production code that makes them pass