DEV Community

Discussion on: What "accepted truth" in software development do you find questionable?

 
dystroy profile image
Denys Séguret

I get what they mean but I disagree.

But I might have a different approach to tests: It is my opinion that, just like it's useless to add a "return the thing" comment in front of every getter, it's useless to add mundane tests which can't fail. A test is a piece of code, which you must understand, maintain, and which must have a reason. A test is needed when you may imagine the tested function might fail (even if you can't imagine how).

The main reason to test a function isn't because it's public, but because it might fail.

Most public API reduce the possibilities of the underlying core, for various reasons. But as the implementer of this core, you still may want to ensure the core does what it's supposed to do.

And a public API offers most often many ways to call the same underlying implementation. Refusing to test the implementation would involve duplicating the tests for all facades, which means you bloat your tests.

Thread Thread
 
renegadecoder94 profile image
Jeremy Grifski • Edited

Now this is an argument I can get behind.

There is some amount of white box testing that I think is important. How do you know a public API works if you don’t test the limits of the internals? Do you just blindly throw inputs at it and hope for the best?