File tree 1 file changed +25
-0
lines changed
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.
61
61
62
62
(defexpect named String (name :foo ))
63
63
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
+
64
71
; ; if the actual value is a collection, the expected outcome can be an element or subset "in" that collection:
65
72
66
73
(defexpect collections
67
74
(expect {:foo 1 } (in {:foo 1 :cat 4 }))
68
75
(expect :foo (in #{:foo :bar }))
69
76
(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)))))
70
95
```
71
96
72
97
Just 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