logoalt Hacker News

bluGilllast Tuesday at 9:55 PM4 repliesview on HN

Your tests are an assertion that 'no matter what this will never change'. If your interface can change then you are testing implementation details instead of the behavior users care about.

the above is really hard. A lot of tdd 'experts' don't understand is and teach fragile tests that are not worth having.


Replies

8notelast Wednesday at 12:35 AM

https://www.hyrumslaw.com/

your implementation is your interface. its a bit naive or hating-your-users to assume your tests are what your users care about. theyre dealing with everything, regardless of what youve tested or not.

show 1 reply
switchbaklast Tuesday at 11:56 PM

Refactoring is changing the design of the code without affecting the behaviour.

You can change an interface and not change the behaviour.

I have rarely heard such a rigid interpretation such as this.

imiriclast Wednesday at 5:15 AM

> Your tests are an assertion that 'no matter what this will never change'.

That's a strange definition. A lot of software should change in order to adapt to emerging requirements. Refactorings are often needed to make those changes easier, or to improve the codebase in ways that are transparent to users. This doesn't mean that the interfaces remain static.

> If your interface can change then you are testing implementation details instead of the behavior users care about.

Your APIs also have users. If you're only testing end-user interfaces, you're disregarding the users of your libraries and modules, e.g. your teammates and yourself.

Implementation details are contextual. To end-users, everything behind the external UI is an implementation detail. To other programmers, the implementation of a library, module, or even a single function can be a detail. That doesn't mean that its functionality shouldn't be tested. And, yes, sometimes that entails updating tests, but tests are code like any other, and also require maintenance and care.

show 1 reply
gchamonlivelast Wednesday at 4:17 AM

Sure if you are changing your interfaces a lot you either are leaking abstractions or you aren't designing your interfaces well.

But things evolve with time. Not only your software is required to do things it wasn't originally designed to do, but your understanding of the domain evolve, and what once was fine becomes obsolete or insufficient.