3 ms·
This one is pretty basic, but it's still very important, and even though it is basic, many tests fail this basic rule all the time. Sometimes it's not really th
by jchw 2y ago
This one is pretty basic, but it's still very important, and even though it is basic, many tests fail this basic rule all the time. Sometimes it's not really the test's fault: the fact that it's hard to make the test failure actionable actually reveals a design failure in the code. Protip: very seldom does it make sense for a function to return a boolean value indicating success or failure. (If you're a C++ person who hates or for other reasons, can't use exceptions, I hear you: my personal preference is something like expected<T> or StatusOr. I am a bit sad that C++ error handling still remains as fragmented as ever...)
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.)