- Good tests are good documentation.
- Testable code is readable code (most of the time).
- Good tests guard against future regressions.
- Code is for humans, not for computers.
- Testable code allows for refactoring with confidence.
- Hard-to-understand code is bad for everyone.
- You should care.
- then integration tests
- then end-to-end (feature) tests
- then QA
- Write list of comment expects
- Simplest case first
- Explain the desired behavior for various contexts
- Write the tests so that they fail
- Write the code so that they pass
- Bits are free. Use them.
- Extract any unit-testable blocks, no matter if you think you should or not.
- Each function should do one thing and do it well.
- They are hard to trace.
- They are untestable.
- Always return a value, unless it's for a side effect.
- Never return undefined.
- Inject Dependencies
- Values shifting unpredictably are untestable.
- Pass by reference arguments
- Look out for functions that mutate
- Don't test that Angular works.
- Don't test that Lodash works.
- Don't test that the core library works.
- Great! It works in the success case. What is supposed to happen if it fails?
- Views should be dumb. They should just render their inputs.
It's nice to have 100% coverage, but some things don't need tests. For example:
- Testing a configuration.
- Testing object properties that aren't generated.
- Budget time to write good tests.
- setup (Arrange)
- call function (Act)
- expect (Assert)
- Luke Brown
- Ricky Hanna
- Ted Lorts