[racket] Running subset of RackUnit tests

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Nov 21 15:00:31 EST 2014

I would use submodules to manage selective testing, like this: 

#lang racket

(provide
  ;; -> Void
  ;; does foo and bar
  main)

;; -----------------------------------------------------------------------------
;; implementation

(require 2htdp/image)

;; -----------------------------------------------------------------------------
(define (main)
  (displayln `(foo and bar)))

(module+ test
  (require rackunit)
  (check-equal? (main) (void)))

(module+ io-test
  (require rackunit)
  (check-equal? (with-output-to-string main) "(foo and bar)"))


Now run: 


> $ raco test -s io-test foo.rkt
> raco test: (submod "foo.rkt" io-test)
> --------------------
> FAILURE
> actual:     "(foo and bar)\n"
> expected:   "(foo and bar)"
> name:       check-equal?
> location:   (#<path:/Users/matthias/Hub/P1/bootstrap-transfer-algebra/foo.rkt> 23 2 426 59)
> expression: (check-equal? (with-output-to-string main) "(foo and bar)")
> 
> Check failure
> --------------------
> 1/1 test failures
> $ matthias% raco test foo.rkt
> raco test: (submod "foo.rkt" test)
> (foo and bar)
> 1 test passed


Posted on the users mailing list.