This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-19
Channels
- # announcements (37)
- # aws (6)
- # babashka (12)
- # babashka-sci-dev (16)
- # beginners (83)
- # biff (10)
- # cider (14)
- # cljdoc (26)
- # cljs-dev (20)
- # clojure (123)
- # clojure-czech (9)
- # clojure-europe (26)
- # clojure-nl (4)
- # clojure-norway (20)
- # clojure-spec (7)
- # clojure-uk (6)
- # clojured (14)
- # clojurescript (28)
- # cursive (5)
- # datalevin (8)
- # datomic (3)
- # duct (6)
- # emacs (26)
- # events (2)
- # fulcro (7)
- # gratitude (1)
- # holy-lambda (19)
- # integrant (1)
- # jobs (2)
- # leiningen (8)
- # lsp (7)
- # nyc (1)
- # pathom (70)
- # re-frame (8)
- # reagent (15)
- # releases (1)
- # sci (8)
- # shadow-cljs (117)
- # testing (5)
- # tools-deps (11)
- # vim (5)
I do like the Midge-like DSL, but it's so unpredictable that I prefer not to use it. In fact, http://gitlab.com/mauricioszabo/check (my testing library) implements a DSL-like approach, but with a single macro that expects 3 args: actual
, matcher
, and expected
. It also implements, with the same macro, a clojure-test based approach, so I can use it as (check (+ 1 2) => 3)
or (check (=> 3 (+ 1 2)))
. Some people prefer the first, some prefer the second.
I built this library for some reasons. First, because I wanted to use a midje-like library but most did not support ClojureScript that well at the time; second, because I wanted better errors (so there's even a defmatcher
if none of the current matchers work); and third, because I needed async testing in ClojureScript, and most libraries get this wrong in some way or other...
I don't think Dragan uses Slack, but this seems like a worthy use of Midge: https://github.com/uncomplicate/clojure-sound/blob/master/test/clojure/uncomplicate/clojure_sound/sampled_test.clj
Midje is great, the trouble is to get the macros and the syntax in the right positions. For example, this code:
(facts "Getting a mixer."
(pos? (count (mixer-info))) => true
(keys (info (first (mixer-info)))) => [:description :name :vendor :version]
(info (first (mixer-info)) :vendor) => "ALSA ()"
(mixer) => (mixer nil)
(mixer (first (filter #(includes? (info % :name) "[default]") (mixer-info)))) => (mixer))
It works, but if you add a let
between facts and the assertions, it sometimes broke with strange errorsBut only sometimes, not always, and the error was like "midje did not understand something you wrote" which was not helpful at all
(BTW, that example translates almost line-by-line to my library check
- you just need to replace facts
for clojure.test/testing
, and wrap every assert (the code, the arrow, and expected result) into check
, like (check (pos? (count (mixer-info))) => true)
for example)