Skip to content

Commit

Permalink
update docs to reflect new failure messages in 2.1.182
Browse files Browse the repository at this point in the history
  • Loading branch information
seancorfield committed Sep 30, 2023
1 parent 17fcc28 commit ebf132b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Only accretive/fixative changes will be made from now on.
* 2.1.182 -- 2023-09-29
* Improved failure reporting: most failures now provide an additional message describing the failure as well as improving how the expected and actual values are displayed (primarily hiding `=?` and showing a more accurate/intuitive test form).
* Update `deps.edn` to use `:main-args` (instead of `:main-opts`) for parameterized tasks in `build.clj` -- see [Running Tasks based on Aliases](https://clojure-doc.org/articles/cookbooks/cli_build_projects/)
* Drop support for Java 8.
* Drop support for Java 8 (it may continue to work but it is no longer tested).
* Update dependencies to latest stable versions.

* 2.0.165 -- 2023-01-31
Expand Down
10 changes: 6 additions & 4 deletions doc/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ It's worth noting that the default output from `in` can be somewhat confusing an

;; default output
FAIL in () (...:...)
within: (expect {:foo 1} (in {:bar 2}))
expected: (=? e__206__auto__ (clojure.core/select-keys a__203__auto__ (clojure.core/keys e__206__auto__)))
actual: (not (=? {:foo 1} {}))
(in {:bar 2})

expected: (expect {:foo 1} (in {:bar 2}))
actual: (not= {:foo 1} {})

;; with Humane Test Output:
FAIL in () (...:...)
within: (expect {:foo 1} (in {:bar 2}))
(in {:bar 2})

expected: {:foo 1}
actual: {}
diff: - {:foo 1}
Expand Down
2 changes: 1 addition & 1 deletion doc/fixtures-focus.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Cognitect's `test-runner` also has an `:includes` option to include only tests m
> clojure -X:test :includes '[:negative]'
```

This run's _only_ tests marked as being `^:negative`.
This runs _only_ tests marked as being `^:negative`.

Leiningen's approach uses an additional layer in its `project.clj` file where you specify `:test-selectors` which are labels for predicates that run on the metadata of tests to determine whether to include them or not. Run `lein test help` for details. The equivalent of the above "humane" run would be:

Expand Down
40 changes: 25 additions & 15 deletions doc/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ If an expectation on a Spec fails, you get the explanation as well as the standa
;; when run:

FAIL in (spec-failure) (...:...)
420 - failed: (< % 100) spec: :small/value
(* 14 30)

expected: (=? :small/value (* 14 30))
actual: (not (=? :small/value 420))
```
val: 420 fails spec: :small/value predicate: (< % 100)

> The `=?` operator appearing here is an Expectations extension to `clojure.test` that provides an "intelligent equality" that supports predicates and Specs, as well as regular value equality.
expected: (s/valid? :small/value (* 14 30))
actual: (not (s/valid? :small/value 420))
```

## Failure Messages

Expand All @@ -237,7 +237,11 @@ user=> (failure-msg)

FAIL in (failure-msg) (...:...)
It's uneven!
expected: (=? even? (+ 1 1 1))
(+ 1 1 1)

(+ 1 1 1) did not satisfy even?

expected: (even? (+ 1 1 1))
actual: (not (even? 3))
nil

Expand All @@ -250,10 +254,12 @@ user=> (spec-failure-msg)

FAIL in (spec-failure) (...:...)
Too big!
420 - failed: (< % 100) spec: :small/value
(* 14 30)

expected: (=? :small/value (* 14 30))
actual: (not (=? :small/value 420))
val: 420 fails spec: :small/value predicate: (< % 100)

expected: (s/valid? :small/value (* 14 30))
actual: (not (s/valid? :small/value 420))
nil

;; expecting adds its message too:
Expand All @@ -269,18 +275,22 @@ user=> (another-spec-failure-msg)
FAIL in (another-spec-failure-msg) (...:...)
Large number should fail
Too big!
420 - failed: (< % 100) spec: :small/value
(* 14 30)

val: 420 fails spec: :small/value predicate: (< % 100)

expected: (=? :small/value (* 14 30))
actual: (not (=? :small/value 420))
expected: (s/valid? :small/value (* 14 30))
actual: (not (s/valid? :small/value 420))

FAIL in (another-spec-failure-msg) (...:...)
Negative number should fail
Too small!
-420 - failed: pos-int? spec: :small/value
(* -14 30)

val: -420 fails spec: :small/value predicate: pos-int?

expected: (=? :small/value (* -14 30))
actual: (not (=? :small/value -420))
expected: (s/valid? :small/value (* -14 30))
actual: (not (s/valid? :small/value -420))
nil
```

Expand Down
5 changes: 3 additions & 2 deletions doc/side-effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ Here's the output of running those two tests:
user=> (my-code-test-1)

FAIL in (my-code-test-1) (...:...)
(side-effects [my-pred println] (my-code 42))

expected: (=? [[42] ["good"]] (side-effects [my-pred println] (my-code 42)))
actual: (not (=? [[42] ["good"]] [(42) ("bad")]))
expected: (= [[42] ["good"]] (side-effects [my-pred println] (my-code 42)))
actual: (not= [[42] ["good"]] [(42) ("bad")])
nil
user=> (my-code-test-2)
nil
Expand Down

0 comments on commit ebf132b

Please sign in to comment.