As an experiment, next.jdbc migrated to LazyTest, using the experimental clojure-test API: https://github.com/seancorfield/next-jdbc/pull/297
I created an issue for Clojure 1.10 support, since I'd like to still be able to test against that version.
The deftest -> defdescribe / it nil means everything is an "Anonymous test case" which looks odd but other than reusing the test name as the docstring there, I'm not sure what would be better:
Long term, explicitly using defdescribe and it would be better of course but this was a relatively painless migration for now.
I still think mapping testing to it might be better than the current implementation (I think we've had this discussion before but I can't remember the outcome?).
Having a convenience macro for (thrown? ex form) -> (throws? ex (fn [] form)) might be nice to help migrations like these @nbtheduke :)
https://cljdoc.org/d/io.github.noahtheduke/lazytest/1.5.0/api/lazytest.core#throws? and https://cljdoc.org/d/io.github.noahtheduke/lazytest/1.5.0/api/lazytest.core#throws-with-msg? exist, but given we're the only users, i'm open to changing the name or adding an alias
those expect a function tho, not merely a form
the issue with mapping testing to it is that means you can't nest testing blocks and that would be a no-go in the code bases i've worked with
oh you mean in the clojure-test interface, yeah that makes sense
if i'd scrolled through your PR i would have seen that you know about throws and throws-with-msg lol
Oh, you can't nest it? That must have been the reason...
tho it pains me, i can support 1.10 lol, and adding thrown? and thrown-with-msg? macros is perfectly reasonable
And, yeah, that mapping for thrown? would deal with the form/fn change in usage.
Remind me, why can't you nest it?
it defines a no-arg function that's executed by the runner. if you nest an it, the nested one will evaluate to a map with {:body (fn [] ...) :context ...} which is inert
Ah, and deftest already maps to describe/it so that's why you can't use it inside it...
ah yeah, that's right. i forgot how sandra had done the deftest interface. clojure.test allows arbitrary code inside, so folks write tests that assume that deftest will execute like one big function definition. lazytest's default requires a little more care (can't use binding everywhere, etc), which is why lazytest/deftest has the implicit it
Yeah, in some tests I would want deftest/testing to map to defdescribe/it, but in others I'd want it to work the way it already does:grin:
I updated my PR to use the Clojure 1.10 PR I just opened against LazyTest, so it's testing 1.10, 1.11, and 1.12 again 🙂
https://github.com/NoahTheDuke/lazytest/pull/17 -- sorry, my OCD required me to sort .gitignore after I'd excluded Calva and Portal files!
I didn't go so far as to add multi-version testing, but that's probably something that should happen at some point.