The Golden Rule of API Design.
(trying to say this is the punchiest way that I can in the hope that the meme travels far..)
It's not enough to write tests for an API you develop, you have to write unit tests for code that uses your API.
When you do, you learn first-hand the hurdles that your users will have to overcome when they try to test their code independently.
What a great insight.
So... develop the API and, at the same time, develop example applications and demos that use the API test-first, and then feed that learning back into the API as you go.
I often do that, but I've never noticed what I was doing or realised the value of the practice before.
So... develop the API and, at the same time, develop example applications and demos that use the API test-first, and then feed that learning back into the API as you go.
I often do that, but I've never noticed what I was doing or realised the value of the practice before.
It's just been something I've been dealing with a lot lately, APIs that make testing impossible. If only everyone was doing what you do you.
We deal with this all the time. The way we do it is we don't implement the api we implement 2/3 example applications and derive the api as we go. That isn't always possible since there might be another team waiting for your api, but sometimes it is.
The Rails meme of "frameworks as abstractions" is good, but not enough for TDD -- this is exactly why. Nice one.
Add Child Page to TheGoldenRuleOfApiDesign