lazytest

seancorfield 2025-03-08T01:38:46.300679Z

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:

seancorfield 2025-03-08T01:40:24.252929Z

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?).

seancorfield 2025-03-08T01:45:56.828689Z

Having a convenience macro for (thrown? ex form) -> (throws? ex (fn [] form)) might be nice to help migrations like these @nbtheduke :)

2025-03-08T02:22:42.360459Z

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

2025-03-08T02:23:45.536479Z

those expect a function tho, not merely a form

2025-03-08T02:25:39.075899Z

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

2025-03-08T02:26:38.631649Z

oh you mean in the clojure-test interface, yeah that makes sense

2025-03-08T02:33:31.183829Z

if i'd scrolled through your PR i would have seen that you know about throws and throws-with-msg lol

seancorfield 2025-03-08T02:40:52.160309Z

Oh, you can't nest it? That must have been the reason...

2025-03-08T02:41:45.238319Z

tho it pains me, i can support 1.10 lol, and adding thrown? and thrown-with-msg? macros is perfectly reasonable

seancorfield 2025-03-08T02:41:52.912639Z

And, yeah, that mapping for thrown? would deal with the form/fn change in usage.

seancorfield 2025-03-08T02:44:30.842959Z

Remind me, why can't you nest it?

2025-03-08T02:47:33.427359Z

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

seancorfield 2025-03-08T02:49:50.222829Z

Ah, and deftest already maps to describe/it so that's why you can't use it inside it...

2025-03-08T02:53:37.569209Z

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

seancorfield 2025-03-08T03:02:21.504049Z

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:

😂 1
seancorfield 2025-03-08T20:36:16.666129Z

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 🙂

🎉 1
seancorfield 2025-03-08T20:22:26.175189Z

https://github.com/NoahTheDuke/lazytest/pull/17 -- sorry, my OCD required me to sort .gitignore after I'd excluded Calva and Portal files!

😂 1
seancorfield 2025-03-08T20:24:08.132679Z

I didn't go so far as to add multi-version testing, but that's probably something that should happen at some point.