views:

32

answers:

1

Why do so many assertEquals() or similar function take the expected value as first parameter and the actual one as second ?
This seems counter-intuitive to me, so is there a particular reason for this unusual order ?

+1  A: 

Because the authors had a 50% change of matching your intuition.

Because of the other overload

assertWhatever(explanation, expected, actual)

And the explanation, which is part of what you know, goes with the expected, which is what you know, as opposed to the actual, which you don't know at the time you write the code.

bmargulies
However in that case, it becomes slightly inconsistent because in most languages, the required parameters appear first, and the mandatory ones last.This is why I would more naturally go for assertWhatever(actual, expected [,explanation])
jor
Sorry, I meant the _optional_ ones appear last, not mandatory...
jor