File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,37 @@ this library to wrap your tests.
6161
6262(defexpect named String (name :foo ))
6363
64+ ; ; the expected outcome can be a Spec:
65+
66+ ; ; assumes (require '[clojure.spec.alpha :as s])
67+ (s/def ::value (s/and pos-int? #(< % 100 )))
68+ (defexpect small-value
69+ (expect ::value (* 13 4 )))
70+
6471; ; if the actual value is a collection, the expected outcome can be an element or subset "in" that collection:
6572
6673(defexpect collections
6774 (expect {:foo 1 } (in {:foo 1 :cat 4 }))
6875 (expect :foo (in #{:foo :bar }))
6976 (expect :foo (in [:bar :foo ])))
77+
78+ ; ; just like clojure.test's testing macro to label groups of tests
79+ ; ; you can use expecting to label groups of expectations (this uses
80+ ; ; some of more advanced features listed below):
81+
82+ (defexpect grouped-behavior
83+ (expecting " numeric behavior"
84+ (expect (more-of {:keys [a b]}
85+ even? a
86+ odd? b)
87+ {:a (* 2 13 ) :b (* 3 13 )})
88+ (expect pos? (* -3 -5 )))
89+ (expecting " string behavior"
90+ (expect (more #"foo" " foobar" #(clojure.string/starts-with? % " f" ))
91+ (str " f" " oobar" ))
92+ (expect #"foo"
93+ (from-each [s [" l" " d" " bar" ]]
94+ (str " foo" s)))))
7095```
7196
7297Just like ` deftest ` , the ` defexpect ` macro creates a function that contains the test\( s\) . You can run each function individually:
You can’t perform that action at this time.
0 commit comments