3 ms·
Automated testing is a generically good technique for many things including forcing yourself to have a better API. Code sometimes has to be refactored to make i
by afeller08 6y ago
Automated testing is a generically good technique for many things including forcing yourself to have a better API. Code sometimes has to be refactored to make it more testable, and this refactoring invariably implies a better API.
Write automated tests to hit each part of your API and test the functionality of each thing in isolation. If you find the tests frustrating to write, your users will find the API frustrating to use.
I've written more about this here:
https://bad-code-considered-harmful.blogspot.com/2020/05/test-your-public-api.html https://bad-code-considered-harmful.blogspot.com/2020/05/tes...
By the way, I am not an advocate for TDD. I write my tests at the point when I'm ready to start running them. But I strongly agree with the general claim that TDD makes that says that good unit tests are the closest thing to a panacea you will ever encounter in software development. However, I've also seen projects where the unit tests were just more bloat. Unit tests need to be written to test your API to help you design a better API.