Happy New Year everyone!
The rackunit documentation describes two functions:
From the descriptions both functions seem very similar, - so similar that I'm not sure when I should use which.
I have used
fail in several test cases in patterns like
(fail "some message"))
and everything seems to work fine.
Are there situations when I should use
fail-check instead (for example in
define-check?), and if yes, why wouldn't
fail work there?
(Whatever the answers to my questions are going to be, I wish someone would clarify the use of
fail-check in the documentation. )
fail is a kind of
check. That means if you write:
you will get a nice test report:
fail-check is meant to be used in
define-check. If you use it at the
top-level / module-level:
an exception is thrown, which is uncaught:
Does using fail instead of fail-check work? It appears to, but that's
mostly a coincidence for this implementation. You can imagine a different
RackUnit implementation where this is not the case, so you should avoid it.
I think that mentioning
define-check in the
fail-check documentation is a
good idea, since they should be cooperating with each other. Note that
define-check already mentions
Thanks to @sschwarzer for letting me know my message was incorrectly processed by Discourse. I fixed the above reply. It appears Discourse will remove any content after a horizontal line when posted from email. Let’s see if this is true (sorry for a bit off-topic):
Well, definitely use
The documentation of
Good for creating test stubs that you intend to fill out later.
So that’s how it’s intended to be used.
I read this, but I think mentioning that it's useful for stubs doesn't automatically say that this is the only use. So this is still a bit vague in my opinion.