lazytest

seancorfield 2025-03-15T19:26:50.689939Z

I noticed that in the mapping namespaces, deftest => defdescribe > it and testing => binding that pushes strings (and the reporting uses that dyn var); however defexpect => defdescribe (with > it in my PR) and expecting => describe which seems to lose information. Then I tried this:

(defdescribe one "two"
  (it "four"
    (describe "three"
      (describe "five"
        (should (= 13 42))))))
and it seems like you can't nest describe inside it (or rather it loses the docstrings in the failure) whereas
(defdescribe one "two"
  (describe "three"
    (describe "four"
      (it "five"
        (should (= 13 42))))))
keeps the nesting (so the failure is reported in two > three > four > five "as expected". That's a bit counter-intuitive to me.

2025-03-15T19:32:04.810009Z

i didn't base the expectations mapping on deftest but on lazytest

2025-03-15T19:34:37.215729Z

describe creates a suite, a testing context object (plain map) with a :children entry that holds all of the nested suites and test cases

2025-03-15T19:35:47.883289Z

so calling it inside it will return a plain map (with the results of the assertion) and if the assertion throws, only the it will catch it

seancorfield 2025-03-15T21:00:52.003779Z

Okay, that wasn't sufficiently clear to me from the docs (re: appropriate nesting of it / describe). It does highlight that the Expectations mapping is problematic (in two ways): • right now, nothing maps to it so there are no actual test cases being created (`defexpect` => defdescribe, expecting => describe, no existing construct => it) • my PR to slip it into defexpect "works" but effectively negates the behavior of expecting (since that would become a nested describe) If the PR is accepted, test cases will "work", but no have any expecting context -- and expecting should be made to behave like testing with the dyn var etc. If the PR is not accepted, in order to have actual test cases, expect (Expectation) would probably need to be mapped to lt/expect-it somehow?

seancorfield 2025-03-15T21:02:03.742109Z

(in Expectations, expecting maps directly to testing:

(defmacro expecting
  "The Expectations version of `clojure.test/testing`."
  [string & body]
  `(t/testing ~string ~@body))
so whatever LazyTest does with testing, it should do with expecting)

2025-03-15T22:03:50.529439Z

yeah that's a good description

2025-03-15T22:04:29.432019Z

you're the sole user of the expectations namespace, so you tell me how you want it to work

seancorfield 2025-03-15T23:39:24.443029Z

Go ahead and merge my existing PR and I'll have a look at testing and see if I can integrate the way that works -- with the dyn var -- into the expectations ns, and I'll update the PR for that when I'm happy...

seancorfield 2025-03-16T00:39:41.832799Z

OK, that was easier than I expected. PR updated. The PR has a note about changing deftest slightly (using the test name in it) but I'll leave that up to you. I'm happy with the Expectations behavior at this point, with this PR.

👍 1
2025-03-15T22:05:27.796069Z

i'll add thoughts to the documentation detailing when/how to nest the various functions