Testin’, What is it Good For?

Not quite absolutely nothin’, but I am starting to wonder.

More tests means more coverage means more green that changes to red at the slightest change. 100% test coverage means 0% freedom to change a line of code without changing a test as well.

At the start of the month we retired a truckload of tests at work, and the world didn’t end. We instated a rule that tests that are red for 3 consecutive days get terminated with extreme prejudice. Always red = no value.

But I have been thinking. What is the value of a green test? I mean, a test that is always green. Tests that have never been red are no more valuable than tests that do not go green. But it is so hard to let go; so tempting to think that a test surely inherently has value.

But do they really?

What makes a test worthwhile? What are tests for? How many?

Bug-free software is a white whale. Every test is a constraint to change. Like any other code, it isn’t free; keeping it is costly. So, I guess the answers are “just enough” and “giving us confidence where we need it” and “when it proves a real invariant truth”.

I just need to work out a practical applications of those holistic answers. But it definitely starts with “less is more”.

3 thoughts on “Testin’, What is it Good For?”

  1. But surely if you make a change and the test goes red then either the code change or the test are wrong? In which case you may have to change the test (then fire the person that wrote the test in the first place.

    As for tests that never fail? Well, there are two kinds of test that never fail. Ones that can never fail, which are pointless and ones that have never failed. The latter can be useful. Imagine Bar foo = new Bar(); which never fails right. Up to the point where someone adds a child object to the class Ewe m_Ewe; then 4 months later someone makes Ewe’s constructor check and throw something. Just because this sounds a little far fetched and contrived means that the likelihood of it happening is close to 100% 😉

    1. I understand. But the fact it might break doesn’t mean it will. And every time a red test needs fixing because the test itself broke is effort that could have gone into a feature. I guess I am just feeling very contrary today!

Comments are closed.