We're updating the issue view to help you get more done. 

Exceptions thrown in tests outside assertions don't report *testing-contexts*

Description

If an exception is thrown within an assertion, Clojure helpfully supplies the testing context (from `testing`) to guide the developer to the problematic code. But if that exception is thrown outside an assertion, it only supplies the name of the test (from `deftest`), which is very vague.

In practice I often have situations like this minimal example:

1 2 3 4 (deftest a-test (testing "a feature" (let [some-value (setup-function-which-throws)] (is (= 1 some-value)))))

Assuming that the `deftest` contains dozens of `testing` blocks with nesting beneath them, and the setup `let`s often 4-5 bindings, it can be quite tedious to trace the exact cause of the failure by digging through the stack trace.

I had a brief look at the code and believe that if clojure.test/test-var would report `testing-contexts` in this case, that would be a simple and cheap quality of life improvement for developers.

Environment

Tested on Clojure 1.10.1 and earlier

Status

Assignee

Unassigned

Reporter

Alex Miller

Labels

None

Approval

None

Patch

None

Priority

Major