> On May 22, 2020, at 18:47, Shriram Krishnamurthi <shri...@gmail.com> wrote:
> As an aside, I'm not entirely sure what `test-log!` is there for. Presumably 
> it's to record in the log "tests" run by operations that are not part of 
> rackunit? I'm curious how people have used it.

Other people have answered other parts of your question, but I don’t think 
anyone has answered this point. The answer is that test-log! isn’t really part 
of RackUnit at all—it comes from the module rackunit/log, but note that it 
comes from the package testing-util-lib, not rackunit-lib. (I can’t say for 
certain, but my guess is that the module is named rackunit/log for historical 
reasons more than anything else.)

test-log! is really mostly an API for cooperating with `raco test`. When you 
run `raco test`, you’ll find that it reports how many tests were run and how 
many of them passed, even if you test multiple modules at once. Somehow, test 
frameworks need to communicate this information to `raco test`, and test-log! 
is the mechanism through which they do that.

Aside from that, `raco test` mostly just instantiates modules in the usual way. 
All of the other success or failure reporting is just ordinary side-effectful 
printing performed by test frameworks themselves. All of RackUnit’s “check info 
stack” machinery is specific to RackUnit; `raco test` doesn’t know or care 
about that at all. RackUnit calls test-log! internally during execution of each 
check, so if you use define-check, you don’t have to call test-log! yourself 
(and indeed, you shouldn’t, or else your tests will be counted twice).

> TL;DR: If I want to record what happened on all the checks for post-execution 
> processing, do I need to (a) create my own log and, to do so, (b) rewrite all 
> the checking predicates to provide the information that the detailed log 
> needs?

As the above explanation implies, if you don’t want to use RackUnit, you can do 
whatever you want. You can print your own (arbitrary) messages upon failure, 
and if you want to integrate with `raco test`, you should just make sure to 
call test-log! once for each executed test case.

If you do want to use RackUnit, then yes, you have to cooperate with all of 
RackUnit’s machinery for implementing checks. Personally, I find RackUnit’s 
design frustrating here. As you have discovered, checks aren’t very 
compositional, so it’s not easy to implement a new check in terms of an 
existing one (while still providing good error messages on failure).

If what you’re doing is difficult to express in RackUnit, consider just 
ditching it and doing your own thing. Test suites in Racket are just simple, 
side-effectful programs, and RackUnit doesn’t do that much all things 


You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to