rackunit icon indicating copy to clipboard operation
rackunit copied to clipboard

Only immediate test case names are printed in check failures

Open jackfirth opened this issue 8 years ago • 0 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.

jackfirth avatar Jul 02 '17 06:07 jackfirth