Fork me on GitHub
#testing
<
2023-07-04
>
Eitan19:07:29

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 Towers19:07:24

@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

Eitan02:07:30

Thank you. I’ll try in a bit.

Eitan20:07:14

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.