Test Failures Should Be Actionable
testing.googleblog.com
testing.googleblog.com
TotT is one of those kinds of things that I really miss from Google. None of the TotTs were exactly groundbreaking, but they almost all made for excellent rules of thumb that would rarely ever be bad advice, and often times even if they seemed simple and obvious, you could still find places to apply them in your actual codebase. (TotT definitely nudged me into making some test improvements when I worked at Google.)
My favorite test framework of all time, rspec-given[1] (by the late, great Jim Weirich) solved this a different way by using AST introspection to extract both sides of a boolean expression and give a helpful message even with an assertion like: `Then { result == 7 }`
Edit: to make a non-meta point, these sorts of appeals to "please exhibit good behavior" can't stand against economic forces, eg time constraints and KPIs, so I wonder if there isn't a ToolsNotRules[0] implementation which might enforce more introspective assertions.
Edit2: Oh, duh—TDD is the practice which enforces more actionable test failures! After all, an unactionable test failure drives no development. So if you're really keen on actionable failures, try TDD.
0. https://benchristel.github.io/process-to-processes/Fundament...
For websites, security is a big one. Detailed error messages can lead to information exfiltration, exploits, fingerprinting and generally bad things. Long error messages in some network protocols enable amplification attacks.
For general applications, there are commercial reasons. You don't want to enable your users too much, they should be incentivized to buy your pricey platinum premium package after all. Therefore an opaque error message, maybe with some error code but no text and no information, is necessary: The user will need to call support and get the error code decoded and be told in hour-long, tedious and expensive support calls how to fix the error. Actually actionable errors are what makes your company go bankcrupt, especially if you do freemium or OSS+support business models.
But:
> How is it not obvious to the point of pain that you need to know WHY something failed, not only that it failed?
This is obvious to everyone, at least after encountering the first few errors. But that makes it the perfect thing to upsell, to milk your existing customers with a pricier plan. One instance is e.g. Microsoft selling access to their customers' logs to those same customers: https://www.theregister.com/2023/07/20/under_cisa_spressures... (they backpedalled after it blew up spectacularly).
No, I don't like it. Yes, I hate those Ferengi. Changing how things are for the better not only requires recognizing the immediate problems but also why the problem is persisted, and who is to blame for it.
Test naming convention defined there of
[UnitOfWork_StateUnderTest_ExpectedBehavior]
Always resonated with me as from that you could also discern bugs in test code from developer’s intent.
Regressions should be rare; if you get a test failure when you break something's public API then that is already a success - we had the right test case!
That you then maybe need to spend a few minutes finding out exactly what is failing, I can live with that.
(JS with Vitest, etc. is good, Rust - not so much)