This site has moved to! All new content will be posted there, with no ads and a much simpler design. Since the old and new sites have completely different feedback mechanisms (on-page comments vs. email) I’m going to leave this site alone for now to provide access to legacy feedback. All the articles from this site are already available on

Start test names with “should”

The purpose of a test is not just to enforce some behaviour on the code under test. When the test fails it also should provide enough information to understand which behaviour failed, where it failed, and (at least superficially) why it failed. If the only output of a failing test is just a binary value like “FAIL”, that test is only giving one bit of information to the developer. A good test framework will also print the test name and a call stack. We can’t change the call stack much, at least not without changing the semantics of the test, and how to actually write the test itself is a whole other story, but what does a useful test name look like?

A trick I learned from Dave Hounslow, a former colleague, is to start test names with “should”¹. This has a few advantages over test [function name]:

  • It removes redundancy, because the function name should already be in the call stack.
  • It is falsifiable, that is, a person reviewing the test can decide to which degree the name agrees with the actual test. For example, they could point out that should replace children when updating instance verifies that new children are added, but not that old children are removed.
  • It encourages testing one property of the function per test, like should apply discount when total cost exceeds 100 dollars, should create record for valid input, and should return error code 1 for unknown error. test [function name] encourages testing everything the function does (branches, side effects, error conditions, etc.) in one test.
  • It invites the developer to write something human readable. I usually find “test …” names to be clunky to read. This may just be bias after years of using this technique.
  • It is better than a comment explaining what the test does, because the comment will not be shown when the test fails.

¹ Some frameworks require that test names are formatted in some special way, like starting with “test”, using snake case, camel case or other. I’m ignoring that part of the naming for brevity and to avoid focusing on a specific language.

These companies work against your freedom

Most companies have never done anything sufficiently evil to deserve going on this list. This list is reserved for companies which have done at least one thing that was so bad they should not be forgiven for it. I will try my very best never to do anything benefiting them economically, and I hope you will too.

Mein Kampf at OSL

No, this is not some tastelessly titled travel story. During a routine book store stop at Oslo Airport Gardermoen, I felt surprised and slightly uncomfortable seeing Mein Kampf for sale. Two paperback copies, side by side, both with that familiar crumpled back caused by heavyhanded customers checking out random pages. But it’s the sign of a properly civilized society to trust that people will read such a book knowing its significance, and act accordingly. For me the significance is simply this: Anyone who follows a person or book without question is a dangerous, untrustworthy fool.

Not my cup of tea to put it mildly, but a good sign. And Bill Bryson’s At Home is turning out excellent.