3 ms·
>I also personally felt better about doing this since it made it easier to correct API design mistakes before implementing the code and baking them in. How do
by rubber_duck 10y ago
>I also personally felt better about doing this since it made it easier to correct API design mistakes before implementing the code and baking them in.
How do you know you made API mistakes from writing unit tests ? API mistakes become apparent when you integrate stuff and use the API in conjunction with other things (using API in isolated scenarios like unit tests is not really insightful you can figure out those flaws just by looking at the API). This is my primary criticism of TDD - you write tests around the initial bad API and you end up keeping that bad design because you already spent so much time testing that. Implementation errors caught by unit tests are cheaper to fix afterwards then design errors.
My approach is hack together a POC -> refactor that and write tests. If you discard the POC then TDD makes sense to me.
- crdoconnor 10y agoI usually don't do unit test driven development actually. I typically do integration test driven development where the integration test sets up an environment where the code is either interacting with the real thing or a realistic mock version. I don't find unit tests all that useful for integration code - either as tests that find bugs or for doing TDD.