When not to test:
- In a new startup trying to get funding
- It’s too hard to write the test
- It’ll take too long
What is a test?
- Verifies code functionality
- Automated testing
- Manual tests
- It’s too hard to test this.
- This is usually a design flaw.
- Forked processes are hard to test.
- Complicated User Interface stuff.
- It’s better/easier to fix it first.
- You can’t test code in Rake Tasks.
- Testing is hard or Writing code and tests is harder than writing code.
- Is this code for “Testing requires discipline?”
- Don’t test “One shot code.” – You’re only going to run it once, until you need to run it again.
- You don’t have to test migrations.
TDD gives you a regression test suite and better design. Do you not test because of ROI:
- Routine tasks are diminished ROI in design.
- Duplicate code
- Low Risk code
The clock is a global variable. Code coverage:
- Ryan likes to have 100% code confidence.
- Coverage means exercise, not correct functionality.
- Rails’ migration code didn’t get covered and then got crufty.
- Code that is difficult to test is difficult to refactor, reuse, extract, and modularize. It’s a “meta-code smell.”