4 ms·
The theory for test-first is you'll come up with a more testable design, and have better, cleaner, more focused tests if you write them first, then design the c
by npinguy 12y ago
The theory for test-first is you'll come up with a more testable design, and have better, cleaner, more focused tests if you write them first, then design the code based on the tests.
If you write the code first, then try to write the tests after, you may have to refactor code to support testing (if you're not used to writing testable code), or you might end up having to do very convoluted tests to make them work (see above re: 3-level mocks), or you might just accept subpar test coverage
- randomdata 12y agoIf you write code first, how are the tests driving your application? It sounds like, by your description, that "test-last" is code driven development; often making the tests fit the code, rather than the other way around.
- npinguy 12y agoThe second "code" should have been "tests" ;) Edited