Property-Based Testing with PropEr, Erlang, and Elixir:the order of the elements in the comparison expression(page 53)

That’s an interesting question. I don’t think it’s a super conscious choice, but I tend to use the order of other assertion macros, where for example the format is ?assertMatch(Pattern, Expression) (this is the only one where it’s very sensitive, otherwise you just get the expected/actual order reversed in a report).

I think this, along with pattern matching generally having the assertion left-side, makes me compare that way. For example, many years ago, before people used EUnit macro in common test, the pattern for assertions would have just been Expected = lists:last(lists:sort(List)), Expected = biggest(List) and then letting the est crash if it’s wrong.

In this case, I appear to have swapped the order with what I generally use or would suggest to use, since the model should be driving the test!

1 Like