Wrapping macros to ease use of nubank/matcher-combinators when writing Lazytest assertions.
Add nubank/matcher-combinators to your test alias alongside lazytest:
{:aliases
{:test {:extra-deps {io.github.noahtheduke/lazytest {:mvn/version "2.1.0"}
nubank/matcher-combinators {:mvn/version "3.11.0"}}
...}}}
The lazytest.extensions.matcher-combinators namespace only defines two macros, match? and thrown-match?. Everything else from matcher-combinators can be used directly.
match?: Asserts that actual matches expected, where expected can be a value, predicate function, or concrete Matcher. If they don't match, throws a ExpectationFailed, like lazytest.core/expect.thrown-match?: Runs the given expr, and asserts that it throws an exception (defaults to clojure.lang.ExceptionInfo) and that the ex-data matches an expected value (which can be a value, predicate function, or concrete Matcher).For more examples and better documentation, please see matcher-combinators' own documentation.
(ns lazytest.matcher-combinators.example-test
(:require
[lazytest.core :refer [defdescribe describe expect it]]
[lazytest.extensions.matcher-combinators :refer [match? thrown-match?]]
[lazytest.expectation-failed :refer [ex-failed?]]))
(defdescribe matchers-test
(describe "correctly mirrors the assert-expr functionality"
(it match?
(expect (match? {:foo 1} {:foo 1 :bar 2})))
(it thrown-match?
(expect (thrown-match? {:foo 1}
(throw (ex-info "heck" {:foo 1})))))))
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |