I think something is a bit broken with the Expectations support in 1.6.1? I'm just switching deps-new from Expectations to LazyTest and I updated the :require to this:
[lazytest.extensions.expectations
:refer [defexpect expect expecting from-each
more more-> more-of side-effects]]
and when I run clojure -M:test:runner I get no output at all. However, if I change a test so it fails, I get the fail -- but only the failure, no context around it:
(!2009)-> clojure -M:test:runner
Execution error (ExpectationFailed) at (REPL:1).
matches: ""
>>> expected diverges: "xorg.corfield.new.impl-test"
>>> actual diverges: "org.corfield.new.impl-test"
Full report at:
/tmp/clojure-3004742020900254945.edn
I noticed this in a namespace at work too and wasn't sure if I was just doing something wrong.
I converted the first test to defdescribe etc and that is reported just fine -- but it's as if the other tests are not reporting anything.
Again tho', if I change one of the non-reporting Expectations tests to fail, I get that raw failure ExceptionFailed with no context at all.
I get the same behavior with 1.5.0 so it isn't a newly-introduced breakage. Weird. @nbtheduke any ideas?
I'm wondering if this is due to some of the refactoring of the Expectations code in LazyTest in 1.4.1 and/or 1.5.0? And I just didn't notice because I only have passing tests (and not seeing a few Expectations-style tests reported in the massive sea of tests tests).
I changed one of the Expectations tests to deftest/`testing`/`is` (and added the experiment clojure-test support require) and that test does get reported, so the bug is only in the Expectations stuff...
hmmmmmm
Looking at the code, I think the problem is that ?= doesn't expand to (lt/expect ...) (or the calls to (?= ...) are not wrapped in (lt/expect ...) whereas in the legacy Expectations v2 they are wrapped in (is ...)...?
Perhaps that call to ?=-impl is where the lt/expect call is missing?
Hmm, nope, it's not quite that simple.
I'm pretty sure it's that an lt/expect call is missing but now I'm not entirely sure where it should go...
Ah... there's no it anywhere in the expect stack! Is that the problem?
I think defexpect should be this:
(defmacro defexpect
"Given a name (a symbol that may include metadata) and a test body,
produce a standard `lazytest.core` test var (using `defdescribe`)."
[n & body]
(with-meta `(lt/defdescribe ~n (lt/it ~(str n) ~@body)) (meta &form)))
That seems to produce the reporting I would expect (and matches the clojure.test compatibility approach).OK, PR submitted. I tested this locally with deps-new's tests and it works.