This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-06
Channels
- # aleph (15)
- # announcements (2)
- # babashka (121)
- # beginners (62)
- # biff (6)
- # cherry (2)
- # cider (51)
- # clerk (30)
- # cljs-dev (5)
- # clojure (77)
- # clojure-austin (2)
- # clojure-europe (10)
- # clojure-germany (6)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-romania (1)
- # clojure-uk (3)
- # clojurescript (16)
- # core-typed (7)
- # cursive (17)
- # datomic (12)
- # deps-new (11)
- # emacs (7)
- # events (2)
- # fulcro (5)
- # honeysql (2)
- # hyperfiddle (32)
- # introduce-yourself (1)
- # jobs-discuss (2)
- # membrane (18)
- # missionary (2)
- # music (5)
- # polylith (7)
- # reagent (26)
- # releases (5)
- # testing (32)
- # tools-build (14)
- # tools-deps (7)
- # xtdb (8)
Can anyone see the difference here?
expected: {:pairs [{:Sym nil} {:Sym nil}]}
actual: {:pairs [{:Sym nil} {:Sym nil}]}
diff: - {:pairs [{:Sym nil} {:Sym nil}]}
+ {:pairs [{:Sym nil} {:Sym nil}]}
It's a bit of a trick question, but took me a while to figure out...
In "actual", nil
is a symbol and in "expected" it is a nil value.
The real test was much bigger structure. Thought I was going blind...
Might be something for pjstadig.humane-test-output to consider.
Does anyone have any recommendations for testing if a function is called (as part of another function being tested) - not caring what it returns or what parameters it takes. Akin to the 'provided' form for midje, but not using midje?
Expectations has side-effects
for this.
If you don't mind, what's the value for such a call? Seems like a recipe for annoyance down the line if the implementation changes
@U04V70XH6 thank you, will check that out too 🙂
Noah, there's a function that is called and in that function it determines if an email is sent or not. It's pretty opaque, but I want to check that the function that sends the email is not called (or is called depending on what happens surrounding it)
In these cases, i've typically done with-redefs
for the target function and then in the impl store some value from the call in a local atom, and then assert on the contents of the atom
I think that's what a lot of these libs do under the hood?
ah yeah, that's probably true
should have assumed as much!
But to me it screams: refactor so the email-sending-fn is a parameter or part of a "system" passed in as an argument 🙂 (but that's a general side-effect-y thing -- and I don't follow my own advice on that anyway 😞 )
but so far, all my tests now pass. I've just refactored a 2,200 line midje test namespace to clojure test and expectations
congrats!
mockfn was inspired by midje's provided
but tries to keep it simple (no metaconstants and isn't tied to a test framework)
mockfn was inspired by the