Less Is More - Why I Favor Short Tests

We're not going to be looking at any code in this post. We are, however, going to examine the impact the length of the tests we write has on various aspects of the verification process. The "long vs. short tests" debate is something I often have with colleagues and every time I have to re-iterate the same points. Usually I can't touch on all of them because the discussion is cut short or because I just forget to bring some of them up. This post is my attempt at formalizing my point of view, for myself first of all, but also for others.


This is a companion discussion topic for the original entry at https://verificationgentleman.netlify.app/2015/03/08/why-i-favor-short-tests.html

Let me add an addendum. If you are going to write a lot of short tests, don’t write a host of tests that are identical with only a few minor changes. That’s a maintenance nightmare. Instead, write one powerful (short) test that randomizes a lot. Then run that same test with many different seeds and allow parameter settings to be made from the command line.

Too many times I’ve seen a bunch of short tests that all needed to change because the original test they all copied was garbage. I had to make the same fix over and over again.

Agreed! I actually wanted to touch on this topic in a future post: constrained random as a test automation tool.