4 ms·
Depends entirely on the code and the context - if it's something like a library, mostly yes. There I already know what I want the library to do, and writing the
by sudhirj 7y ago
Depends entirely on the code and the context - if it's something like a library, mostly yes. There I already know what I want the library to do, and writing the test first is a great way to get a feel for what the ergonomics are like in actual use. Also a great way to spec out what the library will and will not do. Then I write to make it work, and once the tests are passing I keep refactoring to make it neater and easier to understand, and then maybe add benchmarks and move on to optimization.
If it's an application or framework, I usually drive it from the UI, so tests are more an afterthought or a way to check / ensure something.
I find the best balance is to have thick libraries and thin applications, but YMMV.