You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This library brings `expect`, `more`, `more-of`, etc from Expectations into the
21
-
`clojure.test` world to be used instead of (or in addition to) the familiar `is`
22
-
macro. This library has no dependencies, other than `clojure.test` itself, and
20
+
This library provides a more expressive way to write tests than `clojure.test`,
21
+
while still being fully compatible with `clojure.test` and all its tooling.
22
+
23
+
While `clojure.test` provides basic assertions using `(is (= ... ...))`
24
+
and `(is (thrown? ... ...))`, Expectations additionally supports predicates,
25
+
regular expressions, Specs, and collection-based tests.
26
+
27
+
You can either "mix'n'match" `clojure.test` and `expectations.clojure.test`
28
+
features in your tests, using `deftest` from `clojure.test` or `defexpect` from
29
+
this library to wrap your tests, or you can use `expectations.clojure.test` on
30
+
its own, since it exposes equivalents to all of the top-level `clojure.test`
31
+
functions and macros for dealing with fixtures and running tests.
32
+
33
+
The following are equivalent:
34
+
35
+
```clojure
36
+
(deftestmy-test-1
37
+
(is (=2 (+11)))
38
+
(is (thrown? ArithmeticException (/10))))
39
+
40
+
(defexpectmy-test-2
41
+
(expect2 (+11))
42
+
(expect ArithmeticException (/10)))
43
+
```
44
+
45
+
But you can also do things like:
46
+
47
+
```clojure
48
+
(defexpectmy-test-3
49
+
(expect even? (+11))
50
+
(expect#"foo""It's foobar!")
51
+
(expect::adult-age42)) ; ::adult-age is a Spec
52
+
```
53
+
54
+
See the example REPL session below for more details.
55
+
56
+
This library has no dependencies, other than `clojure.test` itself, and
23
57
should be compatible with all existing `clojure.test`-based tooling in editors
24
58
and command-line tools.
25
59
@@ -29,9 +63,6 @@ Works in self-hosted ClojureScript (specifically,
29
63
[`planck`](https://planck-repl.org)). See
30
64
[Getting Started with ClojureScript](/doc/getting-started-cljs.md) for details.
31
65
32
-
You can either use `deftest` from `clojure.test`, or `defexpect` from
33
-
this library to wrap your tests.
34
-
35
66
## Example REPL Session
36
67
37
68
What follows is an example REPL session showing some of what this library provides. For more detailed documentation, start with [Getting Started](/doc/getting-started.md) and work your way through the sections listed there.
@@ -78,7 +109,7 @@ What follows is an example REPL session showing some of what this library provid
78
109
79
110
(defexpectnamedString (name:foo))
80
111
81
-
;; the expected outcome can be a Spec (require Clojure 1.9 or later):
`expectations.clojure.test` supports the following features from Expectations so far:
200
+
TL;DR: Because I liked the ["Classic" Expectations library](https://clojure-expectations.github.io) but didn't like having to use custom, Expectations-specific tooling.
170
201
171
-
* simple equality test
172
-
* simple predicate test
173
-
* spec test (using a keyword that identifies a spec)
Aside from the obvious difference of providing names for tests -- essential for
220
262
compatibility with `clojure.test`-based tooling -- here are the other differences
@@ -235,7 +277,7 @@ To test, run `clj -X:test` (tests against Clojure 1.9).
235
277
Multi-version testing:
236
278
237
279
```
238
-
for v in 1.9 1.10
280
+
for v in 1.9 1.10 1.11 1.12
239
281
do
240
282
clojure -X:test:$v
241
283
done
@@ -244,7 +286,7 @@ done
244
286
You can also run the tests with Humane Test Output enabled but you need to exclude the negative tests because they assume things about the test report data that HTO modifies:
245
287
246
288
```
247
-
for v in 1.9 1.10
289
+
for v in 1.9 1.10 1.11 1.12
248
290
do
249
291
clojure -X:test:$v:humane :excludes '[:negative]'
250
292
done
@@ -292,6 +334,6 @@ This will set you up with `defexpect` and `expect`. Add others as required.
0 commit comments