Fork me on GitHub

Hello everyone. I kinda miss having factories(as factory girl in Ruby) in clojure, I didn't even have to really write in the database and this felt like an advantage, how would you approach that in clojure?


You might enjoy using the generators from test.check


thiagofm: personally, i don't think mocking actual services is a very good idea, since you might be missing some important integration tests


lmergen: I'm reading articles that support your point, but in the end I think it's really about tradeoffs, it makes things a bit easier to write


When working with services, I prefer to write a protocol, write a impl that hits the service, and an integration test that actually interacts with the service. For other tests, I’ll reify an impl that provides the behavior I need to exercise the conditions about which I care.


The utility of this approach is bounded by the complexity of system’s interaction with the service tho. Works great for a key-value store, not so well for a relational database unless only used in narrow ways.


@donaldball: do you anything explaining this approach in detail? Sounds good


i actually create ad-hoc databases in my test's fixtures


it's a tradeoff, and i can definitely see pros and cons for both sides


but imho, if you're not testing integrations in your lein test, you're simply moving that problem to be tested in a later phase, which you will probably have to automate anyway


so it's best to just automate it as early as possible