Why are assertEquals() parameters in the order (expected, actual)?

前端 未结 7 1876
余生分开走
余生分开走 2021-01-31 01:28

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,

7条回答
  •  不要未来只要你来
    2021-01-31 01:55

    Because the authors had a 50% chance 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.

提交回复
热议问题