canonical-ci-engineering team mailing list archive
-
canonical-ci-engineering team
-
Mailing list archive
-
Message #00565
It's expected, actual, I mean it
Hi,
This is more than a pet peeve, I don't want to go into endless debates
like the ones about code style.
Before the meme starts getting out of hand, *I* have a strong preference for:
assert (expected, actual)
I *do* know there is an ongoing controversy on that topic but there is
also an argument nobody was never able to properly answer: diff, patch,
the good old guys, present their output (or input) in the old/new
order. And nobody in their right mind will ever propose to change this.
When I read a failing test output, I expect the same order, 'old' is
what was working and is what the test expect, so it's 'expected'. 'new'
is why the test is failing right now, so it's 'actual'.
And we don't want to have to read the test code to know which order has
been used each time we encounter a test failure, so please, let's settle
on expected, actual.
Our project is still young enough that we can avoid mixing both styles.
Unlike code style though, there is no way to automatically check that a
test use 'expected, actual' instead of 'actual, expected'.
So we need a small bit of discipline.
Please, pretty please, let's not waste our present (but more importantly
our future) time wondering which style is used for a given test, when
reading the failure outputs or the test themselves.
I have tons of arguments if you need to be convinced but in a nutshell,
I *do* know that the arguments *for* 'actual, expected' are mainly for
the convenience of the test *writer*. And since code is read several
order of magnitude more often than it is written, I do tend to weight
these arguments in the same way ;)
Vincent