This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-02-14
Channels
- # announcements (1)
- # beginners (206)
- # calva (2)
- # cider (64)
- # cljs-dev (12)
- # clojars (2)
- # clojure (177)
- # clojure-europe (2)
- # clojure-finland (1)
- # clojure-italy (2)
- # clojure-losangeles (5)
- # clojure-nl (7)
- # clojure-russia (69)
- # clojure-spec (41)
- # clojure-uk (92)
- # clojurescript (60)
- # core-async (16)
- # cursive (48)
- # data-science (6)
- # datomic (73)
- # duct (5)
- # events (2)
- # figwheel-main (5)
- # fulcro (29)
- # hoplon (1)
- # off-topic (52)
- # pathom (11)
- # reagent (4)
- # reitit (5)
- # remote-jobs (1)
- # rum (7)
- # shadow-cljs (58)
- # slack-help (10)
- # spacemacs (3)
- # testing (3)
- # tools-deps (5)
@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.
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.).