[Haskell-cafe] order of assertEqual arguments is counterintuitive

Richard O'Keefe raoknz at gmail.com
Wed Mar 2 10:21:59 UTC 2022

Little point of history:  the xUnit family of unit testing
frameworks originated in *Smalltalk* (SUnit), which is why
the graphic user interface for running tests was a standard
part of it.  It wasn't just that you could drive tests from
a graphic terminal, it was that testing was *integrated*
with the IDE.  The Wikipedia page on jUnit gets this right,
acknowledging the priority of SUnit.  Credit should be
given to a specific person: Kent Beck, author of the original
version of SUnit.  It would be good for the HUnit document
to give credit where credit is due.

AS for the interface, what is the problem?
It's always <HUnit function> "some string" <other arguments>.
It doesn't really matter very much whether the observed or
expected value is presented next in assertEqual, but it is
documented as expected-then-observed.

On Wed, 2 Mar 2022 at 06:57, Daneel Yaitskov <dyaitskov at gmail.com> wrote:

> Hi List,
> I noticed, that I pay more attention than I should, when working with
> assertions, because I am not sure about argument order i.e. whether the
> expected value goes first or vice-versa. Does anybody have similar thought?
> Such subtle detail should be easy to grasp with regular practice, but I
> observe difficulties and I suspect that there is a logical reason for that.
> Unit tests appeared long time ago in Java and spread over all languages.
> HUnit library inherited de facto standard assert function name and
> signature. I don't know reasoning behind original signature.
> I spell "assertEqual" expression as:  "Assert that x equals to y"
> "y" sounds like a model value (i.e. expected value).
> In assignments "x <- y" y is the model value, because it defines "x".
> You get "x" - value on the left not on the right.
> Similar issue with test fixing - I always have to check first, that an
> expected value is actually one. There is no type safety preventing mixing
> arguments. I had to open and comprehend a source file with test, because
> test log is not 100% safe.
> --
> Best regards,
> Daniil Iaitskov
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20220302/9d5e258e/attachment.html>

More information about the Haskell-Cafe mailing list