testing

Ingy döt Net 2023-10-06T17:09:57.030589Z

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}]}

Ingy döt Net 2023-10-06T17:10:55.888079Z

It's a bit of a trick question, but took me a while to figure out...

Ingy döt Net 2023-10-06T17:12:14.345819Z

In "actual", nil is a symbol and in "expected" it is a nil value.

Ingy döt Net 2023-10-06T17:13:08.347659Z

The real test was much bigger structure. Thought I was going blind...

Ingy döt Net 2023-10-06T17:14:40.143709Z

Might be something for pjstadig.humane-test-output to consider.

Ingy döt Net 2023-10-06T17:15:00.051839Z

@pjstadig ^^ 🙂

dharrigan 2023-10-06T19:29:45.621499Z

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?

Phillip Mates 2023-10-07T11:06:15.886549Z

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

👍 1
dharrigan 2023-10-06T19:30:58.660509Z

For example, I've stumbled upon this

dharrigan 2023-10-06T19:32:53.517159Z

Perhaps this looks promising too

dharrigan 2023-10-06T19:37:13.166969Z

actually spy works pretty darn well. it'll do 🙂

➕ 1
Derek 2023-10-06T19:39:17.794089Z

https://github.com/nubank/mockfn maybe

dharrigan 2023-10-06T19:42:38.764719Z

thank you,will have a look. Seems like I'm spoilt for choice! 🙂

👍 1
seancorfield 2023-10-06T20:38:38.826579Z

Expectations has side-effects for this.

2023-10-06T20:46:27.164159Z

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

dharrigan 2023-10-06T20:53:21.581629Z

@seancorfield thank you, will check that out too 🙂

dharrigan 2023-10-06T20:54:21.857589Z

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)

👍 1
2023-10-06T20:55:22.842269Z

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

seancorfield 2023-10-06T20:55:46.077829Z

I think that's what a lot of these libs do under the hood?

dharrigan 2023-10-06T20:55:52.818819Z

Yup, including side-effects 🙂

2023-10-06T20:55:57.244419Z

ah yeah, that's probably true

2023-10-06T20:56:20.391599Z

should have assumed as much!

dharrigan 2023-10-06T20:56:37.937649Z

I'm going to try out side-effects tomorrow.

seancorfield 2023-10-06T20:57:00.859419Z

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 😞 )

😅 2
dharrigan 2023-10-06T20:57:13.122069Z

Oh, certainly, refactor++

dharrigan 2023-10-06T20:57:30.291979Z

But time is pressing and I've made a note to come back and revisit it later

dharrigan 2023-10-06T20:57:38.203859Z

and yes, will probably pass the email function in 😉

dharrigan 2023-10-06T20:58:17.320589Z

but so far, all my tests now pass. I've just refactored a 2,200 line midje test namespace to clojure test and expectations

💯 1
💪🏻 1
😮 1
dharrigan 2023-10-06T20:58:20.475079Z

and I'm tired

dharrigan 2023-10-06T20:58:46.832359Z

time for bed and decompression 🙂

2023-10-06T21:00:40.586339Z

congrats!

dharrigan 2023-10-06T21:11:32.313389Z

thank you 🙂 ttfn!