Hi Shriram, I have a module, handy/test-more (https://pkgs.racket-lang.org/package/handy), that I think does everything you want; the downside is that the documentation is thorough but it's in the form of essay-style comment sections instead of Scribble. Breaking that out into actual Scribble is on my todo list but hasn't happened yet. You can read it on GitHub here https://github.com/dstorrs/racket-dstorrs-libs/blob/master/test-more.rkt
If you think you would find this useful, I'll make a point to do the Scribble this weekend. Here's the synopsis statement: ;;====================================================================== ;; The racket testing module has a few things I wish it did differently: ;; ;; 1) The test function names are verbose and redundant. check-this, check-that, etc ;; ;; 2) The test functions display nothing on success. There's no way ;; to tell the difference between "no tests ran" and "all tests ;; succeeded" ;; ;; 3) The tests return nothing. You can't do conditional tests like: ;; (unless (is os 'windows) (ok test-that-won't-pass-on-windows)) Some quick examples; there's quite a lot more that can be done with it if this looks useful. The output is shown after the code. #lang racket (require handy/test-more) (expect-n-tests 4) (test-suite "examples" (struct person (name age) #:transparent) (define people (hash 'alice (person "alice" 19) 'bob (person "bob" 17))) ; basic equality testing (is (* 1 2) 2 "(* 1 2) = 2") (is-false (hash-has-key? people 'charlie) "as expected, don't know charlie") (isnt (hash-has-key? people 'charlie) "same as above") ; Tests return values so you can chain them or nest them (lives (thunk (and (ok (hash-has-key? people 'alice) "we have an entry for alice") (let ([alice (hash-ref people 'alice)]) (is (person-age alice) 19 "alice is 19") (like (person-name alice) #px"^alice$" "alice's name is string, lowercase, trimmed")))) "alice-related tests did not raise exception") ; exceptions (define thnk (thunk (+ 1 "foo"))) (dies thnk "it died, that's all I care about") (throws thnk exn:fail:contract? "match against an arbitrary predicate") (throws thnk #px"expected: number.+\"foo\"" "match against a regex") (is (throws thnk (lambda (e) 'ok) "throws can pass exn to arbitrary one-arg proc for testing") 'ok #:op (lambda (got expected) (if (exn? got) 'ok 'nope)) "tested 'throws' with hand-rolled predicate, then chained into `is` using hand-rolled equality testing (the equality test is illustrative but not sensible)") ) When you run the above code, the following will be sent to STDOUT. Note that it tracks the number of tests it runs, numbers them, and warns you that you didn't run the expected number. ######## (START test-suite: examples) ok 1 - (* 1 2) = 2 ok 2 - as expected, don't know charlie ok 3 ok 4 - we have an entry for alice ok 5 - alice is 19 ok 6 - alice's name is string, lowercase, trimmed ok 7 - alice-related tests did not raise exception ok 8 - it died, that's all I care about ok 9 - match against an arbitrary predicate ok 10 - match against a regex ok 11 - throws can pass exn to arbitrary one-arg proc for testing ok 12 - tested 'throws' with hand-rolled predicate, then chained into `is` using hand-rolled e$ ok 13 - test-suite completed without throwing uncaught exception Total tests passed so far: 13 Total tests failed so far: 0 ######## (END test-suite: examples) !!ERROR!!: Expected 4 tests, actually saw 13 On Fri, May 22, 2020 at 7:47 PM Shriram Krishnamurthi <shri...@gmail.com> wrote: > I'm trying to understand the design of the logging portion of rackunit: > > > https://docs.racket-lang.org/rackunit/Testing_Utilities.html#%28part._.Logging_.Test_.Results%29 > > 1. The "log" seems to only be a *count*, not the actual rackunit > output (as the term "log" would suggest). Since I want to show a summary of > tests — including output — on a different medium, after the test suite has > run, it looks like I need to essentially create my own logging support? > (Perhaps the "check-info stack" is useful here, but I don't think so.) > 2. Why do the check-… procedures not return any value? It would seem > natural for them to return, say, false in case of passing and a failure > information structure in case of failing (or a structure in both cases). > But they seem to only return void, so I'm not entirely sure how else to > extract the information for the log without rewriting the check's. > 3. 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. > > 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? > > Thanks, > Shriram > > -- > 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 > https://groups.google.com/d/msgid/racket-users/e7cafb9d-793d-4f3b-9eb4-308e43df73f2%40googlegroups.com > <https://groups.google.com/d/msgid/racket-users/e7cafb9d-793d-4f3b-9eb4-308e43df73f2%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 https://groups.google.com/d/msgid/racket-users/CAE8gKoen28Es97-Epa%3DB_rJX3X2qjDPk_q_h0kvCe7uJiXs_SA%40mail.gmail.com.