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 ?
views:
32answers:
1
+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
2010-03-08 22:12:30
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
2010-03-08 22:39:01
Sorry, I meant the _optional_ ones appear last, not mandatory...
jor
2010-03-09 07:12:14