[racket] Running subset of RackUnit tests

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Nov 21 18:25:53 EST 2014

		
[[ always cc list ]]

(module+ test ...) is a single sub-module that is distributed over the body of a module. Racket collects the pieces and makes a single submodule. 

-- Matthias




On Nov 21, 2014, at 3:13 PM, Joel McCracken <mccracken.joel at gmail.com> wrote:

> How would I run 1) all tests and 2) a selected subset (i.e. multiple
> modules at once)?
> 
> I'm relatively unfamiliar with Racket's module system (other than it
> exists and how to do basic things with it).
> 
> On Fri, Nov 21, 2014 at 3:00 PM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>> 
>> 
>> 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.