Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by Arnavion on Thursday July 15, 2021 @07:52PM
(#27851517)
You've just restated your original comment, without addressing the fact that this does not work with the third example in my original comment.
Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by lhorie on Thursday July 15, 2021 @07:59PM
(#27851583)
How so? You can mock any of bar/baz/quux however you want using the patterns/techniques above. Am I misunderstanding something?
Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by Arnavion on Thursday July 15, 2021 @08:03PM
(#27851621)
Again, your Foo always contains a bar, baz and a quux. And again, the third example in my original post talks about how not every test needs all three.
Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by lhorie on Thursday July 15, 2021 @10:02PM
(#27852327)
Ah, I understand now. My understanding is that with zig and go, one does not DRY deferring, it's just a part of the idiom trade-offs between verbosity and explicitness.
So if bar, baz, quux aren't intrinsically related as a unit and might be mixed and matched arbitrarily, you just forego the whole ceremony and call each thing or the respective mock individually (the argument being that if you're making multiple different permutations, you're not repeating yourself per se; e.g. mocks don't need to be cleaned up in the first place)
There's also something to be said about tests needing several arbitrary mocks. Normally, I'd consider that a smell. I've actually seen the pattern of making a kitchen sink foo for scenarios like that, but with nils/noops for unused things (can't say I like that approach though).
Re:Zig, Skia, Clojure, Geometry and the Japanese TV Show: IC...
by dnautics on Friday July 16, 2021 @12:21AM
(#27853032)
It's a huge code smell. It's funny because just today I was listening to a podcast about testing and they talk about exactly these sorts of contrivances as being a good sign you should not be mocking something in a test.
(https://smartlogic.io/podcast/elixir-wizards/s6e6-matthias-l...) if you're curious
Poor man's:
Explicit injection: Or use some DI frameworkEven if you have reservations about where verbosity lies, I don't see how this affects the cleanup side.