Adam Wathan, Laracon Online 2017
- "Almost all of your tests should be unit tests."
- "Your tests should never touch the database."
- "If you can't test your code in isolation, it's poorly designed."
Are these true?
[Products Controller with injected dependencies, using CommandBus, Repository]
[A look at the test for ProductsController, completely using mocks]
We passed all the alternative fact tests. :) But something isn't right.
And the alternative fact folks would say "YOU'RE STILL DOING IT WRONG!"
TDD is all about the red-green refactoring loop.
- Write a failing test
- Get it to pass
- Refactor at will
If refactoring is a fundamental part of TDD, and isolated testing gets in the way of refactoring, then isolated unit testing is incompatible with TDD.
[Layout of program process and test]
"Isolated Tests are a Scam." - Adam Wathan, 2017
How do you test making payments with Stripe, for example?
Instead, introduce boundaries when they solve a real problem.