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.
@pjstadig ^^ 🙂
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?
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
For example, I've stumbled upon this
Perhaps this looks promising too
actually spy works pretty darn well. it'll do 🙂
thank you,will have a look. Seems like I'm spoilt for choice! 🙂
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
@seancorfield 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?
Yup, including side-effects 🙂
ah yeah, that's probably true
should have assumed as much!
I'm going to try out side-effects tomorrow.
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 😞 )
Oh, certainly, refactor++
But time is pressing and I've made a note to come back and revisit it later
and yes, will probably pass the email function in 😉
but so far, all my tests now pass. I've just refactored a 2,200 line midje test namespace to clojure test and expectations
and I'm tired
time for bed and decompression 🙂
congrats!
thank you 🙂 ttfn!