Fork me on GitHub
#testing
<
2019-02-14
>
metametadata20:02:11

@ljosa check out my lib https://github.com/metametadata/clj-fakes for test doubles. There's also a [outdated] list of alternative libs at the bottom of the readme. Whether mocks should be used or not depends on the style of testing. Personally I prefer writing many unit tests with mocked-out dependencies and minimize writing integration tests. There's a nice overview of different approaches at https://github.com/testdouble/contributing-tests/wiki/Test-Driven-Development.

metametadata21:02:12

I'd also recommend to extract all the dependencies you want to stub as explicit arguments instead of using with-redefs-like helpers. It's easier to maintain in the long run (because it becomes apparent from the API declarations what can/should be stubbed) and is more thread-safe (patching doesn't play well with core.async, concurrent test running, etc.).