Only immediate test case names are printed in check failures
jackfirth opened this issue · comments
Given this program:
#lang racket
(require rackunit)
(test-case "foo"
(test-case "bar"
(check-equal? 1 2)))
The output is:
--------------------
bar
FAILURE
name: check-equal?
location: unsaved-editor:5:4
actual: 1
expected: 2
--------------------
However, if the outer test case is changed to a test suite and run with run-tests
the output is:
--------------------
foo > bar
FAILURE
name: check-equal?
location: unsaved-editor:6:15
actual: 1
expected: 2
--------------------
I think any (run-tests (test-suite body ...))
expression should have the same output for each check failure / error as the equivalent (test-case body ...)
expression. This issue can be fixed by making a (current-test-names)
parameter that returns a list of names of all wrapping tests, using #f
for unnamed tests. This parameter can be captured by check failure exceptions. Then the logic for printing the test name can be moved out of run-tests
and into rackunit/private/format
, simplifying the folding that run-tests
performs.