testing

Eitan 2023-07-04T19:12:29.478609Z

Hello everyone, I am using the clojure/test library and I am running my tests with a fixture that grabs a snapshot at the end of every test. In the fixture I want to get the name of the test so I can make each snapshot distinguishable. What would you folks recommend?

Bobbi Towers 2023-07-04T19:40:24.925099Z

@eitan In the https://github.com/exercism/clojure-test-runner/blob/f8645948acec40ee0069ce794daede2e12631915/test-runner.clj#L111, we do this by overriding clojure.test's reporting methods with ones that capture the results in an atom. There is a dynamic var called clojure.test/*testing-vars* which keeps track of the vars being tested. Depending on what data you need that might be enough, but keep in mind that the order is randomized

Eitan 2023-07-06T20:09:14.056849Z

What you suggested worked. I overwrote the reporting method for :begin-test-var so it stores the name of the test in an atom. I then used what was in the atom for each screenshot I took.

Bobbi Towers 2023-07-06T20:10:11.763929Z

cool!

Eitan 2023-07-05T02:26:30.715929Z

Thank you. I’ll try in a bit.