On Tuesday, 8 May 2018 at 03:57:25 UTC, Johannes Loher wrote:
Fluent assertions have one major advantage over using
pascalCase assertions: There is no ambiuguity about the order
of arguments.
When using e.g. assertEquals, how do you know wheter is is
supposed to be assertEquals(actual, expected), or
assertEquals(expected, actual)? The first one is the only one
that makes sense wirh UFCS, but it is not clear directly from
the API. On top of that, some popular Frameworks (I‘m looking
at you, JUnit...) do it exactly the other
way round.
With fluent assertions, you don‘t have this Problem, it is much
more clear that it should be actual.should.equal(expected) and
not expected.should.equal(actual), because it fits naturally in
the chain of ufcs calls.
Okay, I think I see your point, although it looks to me the added
verbosity and code complexity is not really worth it, provided
you always use UFCS. But of course, that cannot be easily
enforced I guess.