6 Comments
User's avatar
Jay Bazuzi's avatar

A superficially-related pattern I sometimes use, when testing that "operation `O` changes `x` from `a` to `b`:

```

setup()

assert x == a

O()

assert x == b

```

The first assertion isn't actually about testing anything, it's a message to a human reader.

Many people have told me they don't like this because they only want one assertion per test, but I think it's a good exception to that idea.

Paul-Sebastian Manole's avatar

My opinion is that people write tests like this because of the setup phase. If the testing is not done right, if the abstractions are in the wrong place, or they are wrong, or your module seams are not where they should be, it can be really costly to set up the world for a test, so that is why people bunch up multiple assertions in the same test. You see this a lot in E2E tests as well. I think altogether these experiences from writing incorrect test suites lead to this learned behaviour.

Daramola Ben's avatar

I now see run on tests everywhere, especially in agent eval suites where one giant trajectory has twelve assertions and nobody knows which step broke. Naming each one for the person reading the failure is such a good habit.

Patrick's avatar

One addition I would make for such tests, if the test framework allow it, is to change all earlier asserts to assumes. That way if an earlier step fails, all tests that depend on that step will show as inconclusive, making finding the actual failure easier.

gold's avatar

Run on tests, in some form, serve to confirm non-atomic design characteristics. Secondary guardrails, as it were. If a change fouls a unit but not a run on, something is wrong (and vice versa).

rtko's avatar

I hope people still think about this kind of stuff now that we’re in a new age. Quality matters more than ever.