ITADN

defexpect 3-arg fails with alternate assertions

#35ClosedNoahTheDuke 创建于 2024-04-29
needs analysis
N
NoahTheDukecommented
Hey Sean! I have a macro that creates some set-up and then calls `expect` on the results: ```clojure (defmacro expect-match ([expected s] `(expect-match ~expected ~s nil)) ([expected s config] `(let [diagnostics# (check-all ~s ~config)] (expect (~'match? ~expected diagnostics#))))) ``` This works perfectly when I put it in `defexpect` calls, except when I put two of them in a row with no other calls: ```clojure (ns noahtheduke.splint.expectations-test (:require [expectations.clojure.test :refer [defexpect]] [noahtheduke.splint.test-helpers :refer [expect-match]])) (defexpect example-test (expect-match nil "#_:splint/disable (+ x 1)") (expect-match nil "(+ 1 x)")) ``` If they both pass, then it says there's 3 passing tests, and if one of them fails, it shows two failures, the second being the mismatch between the first assertion and the second assertion: ```clojure Testing noahtheduke.splint.expectations-test FAIL in (example-test) (NO_SOURCE_FILE:8) expected: (match? nil diagnostics__28464__auto__) actual: (mismatch (expected nil) (actual ({...}))) FAIL in (example-test) (NO_SOURCE_FILE:6) (expect-match nil "(+ 1 x)") expected: (=? (expect-match nil "#_:splint/disable (+ x 1)") (expect-match nil "(+ 1 x)")) actual: (not (=? true false)) Ran 1 tests containing 3 assertions. 2 failures, 0 errors. {:test 1, :pass 1, :fail 2, :error 0, :type :summary} ``` Is there a way to avoid this behavior besides using plain `deftest`? I don't mind doing that, but it's nice when I can `:require` the one library instead of both (having to pay attention to when I have exactly two assertions in a form).
关闭于 2024-05-04 3 条评论