Superb post on what assertions are, and how to use them effectively:
miniblog.
Related Posts
Assertions are a surprisingly nuanced design space. In a test, if I assert `x < y`, I really want to see the values of x and y when it fails.
Do you define an API for every possible predicate (Python's assertLess, expect.js) or try to support the native syntax (c.f. pytest)?
What piece of syntax has the most different meanings?
I realised today that `as` is extremely overloaded. It can be used for aliasing imports (Python), type casts (Rust), binding pattern match variables (OCaml), type assertions (Hack) and probably many others.
I've seen test runners that report the number of assertions checked, not just the number of tests. Is this useful?
I understand if you have non-fatal assertions (like EXPECT_TRUE in googletest), but I think this is a rare feature in testing libraries.