The problem is that a test-case expression runs a test immediately; it does not return a test object to be run later. In your case, the test runs while my-test-case is being defined, then no test at all actually runs (my-test-case is just #<void>).
A test-suite expression, however, *does* construct a test for running later. You probably want something more like this: #lang racket (require rackunit) (require rackunit/text-ui) (define my-test-suite (test-suite "My test-suite" (test-case "My Test case" (check eq? 1 1)))) (module+ test (run-tests my-test-suite)) Note that test-suites can be nested inside of other test-suites, so you can get modularity back that way if desired. -Jon On Sat, Feb 25, 2017 at 1:17 AM, Alex Harsanyi <alexharsa...@gmail.com> wrote: > I'm a bit confused about how raco test is reporting the number of tests > run, if a test case is defined outside a test suite. If I run the program > below: > > #lang racket > (require rackunit) > (require rackunit/text-ui) > > (define my-test-case > (test-case > "My Test case" > (check eq? 1 1))) > > (define my-test-suite > (test-suite > "My test-suite" > my-test-case)) > > (module+ test > (run-tests my-test-suite)) > > I get: > > $ raco test test/t.rkt > raco test: (submod "test/t.rkt" test) > 0 success(es) 0 failure(s) 0 error(s) 0 test(s) run > 0 > 1 test passed > > the test is clearly run (I even put a printf inside my-test-case to be > convinced of that), yet the first output line indicates that there were 0 > successes and 0 tests run. The last output line seems to be consistent > with the number of tests (checks) run. > > How do I structure my test programs, such that raco test displays the > actual number of tests run? > > Thanks, > Alex. > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.