On Wednesday, December 31, 2014 8:48:27 AM UTC-6, Jonathon McKitrick wrote: > > I use TDD and mocking/stubbing (conjure) to test each layer of my code. > The problem is when I change the function signature and the tests do not > break, because the mocks/stubs do not know when their argument lists no > longer agree with the underlying function they are mocking. Is there a way > to catch this? Short of a test suite that eschews stubbing in favor of > full setup/teardown of DB data for each test? >
I'll second the avoiding mocks, and avoiding midje votes. As for practical advice, I noticed that many times when I had mocking/stubbing problems in my tests, it was because my app was too tightly complected or stateful. I highly highly recommend using https://github.com/stuartsierra/component . Component strongly encourages you to program in a style where it's easy to e.g. replace your DB with an in-memory instance, and make it obvious which fns need DB access, encouraging you to split fns into pure and impure. Also, use core.async to communicate between separate components, where it makes sense. As a design rule, I prefer making I/O fns (things that hit the DB or a REST API), 'dumb', and perform all logic/processing in fns that just receive plain data, and return plain data. When you follow those two practices, your need for stubbing & mocking will drop significantly. As a bonus, your tests usually get faster! Thanks, Allen -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.