Liking cljdoc? Tell your friends :D

lazytest.experimental.interfaces.expectations

EXPERIMENTAL. COULD BE CHANGED AT ANY TIME. Please share usage reports at https://github.com/noahtheduke/lazytest/issues

An adaption of the Clojure library Expectations v2. To mirror how it's built for clojure.test, defexpect wraps the entire test in a single test-case. expecting works the same way as clojure.test/testing, so it does not support metadata selection like lazytest.core/describe. expect is implemented in lazytest.extensions.expectations/expect. None of the utility functions from Expectations v2 are adapted here. They can be found in lazytest.extensions.expectations.

To use just the expect assertion from Expectations v2, please see lazytest.extensions.expectations/expect.

Supported Expectations vars:

Example:

(ns noahtheduke.example-test
  (:require
   [clojure.spec.alpha :as s]
   [lazytest.experimental.interfaces.expectations :refer [defexpect expecting expect]]))

(s/def ::pos pos?)
(defexpect expectations-test
  (expecting "value"
    (expect true))
  (expecting "="
    (expect 1 1))
  (expecting "fn?"
    (let [i 1] (expect pos? i)))
  (expecting "regex"
    (expect #"hello" "hello world"))
  (expecting "instance?"
    (expect String "hello world"))
  (expecting "catch"
    (expect ExceptionInfo (throw (ex-info "aw shucks" {}))))
  (expecting "spec"
    (expect ::pos 1)))
EXPERIMENTAL. COULD BE CHANGED AT ANY TIME. Please share usage reports at https://github.com/noahtheduke/lazytest/issues

An adaption of the Clojure library [Expectations v2](https://github.com/clojure-expectations/clojure-test). To mirror how it's built for `clojure.test`, [[defexpect]] wraps the entire test in a single test-case. [[expecting]] works the same way as `clojure.test/testing`, so it does not support metadata selection like [[lazytest.core/describe]]. [[expect]] is implemented in [[lazytest.extensions.expectations/expect]]. None of the utility functions from Expectations v2 are adapted here. They can be found in [[lazytest.extensions.expectations]].

To use just the `expect` assertion from Expectations v2, please see [[lazytest.extensions.expectations/expect]].

Supported Expectations vars:
* [[defexpect]]
* [[expecting]]
* [[expect]]
* [[in]]
* [[from-each]]
* [[more]]
* [[more-of]]
* [[more->]]

Example:
```clojure
(ns noahtheduke.example-test
  (:require
   [clojure.spec.alpha :as s]
   [lazytest.experimental.interfaces.expectations :refer [defexpect expecting expect]]))

(s/def ::pos pos?)
(defexpect expectations-test
  (expecting "value"
    (expect true))
  (expecting "="
    (expect 1 1))
  (expecting "fn?"
    (let [i 1] (expect pos? i)))
  (expecting "regex"
    (expect #"hello" "hello world"))
  (expecting "instance?"
    (expect String "hello world"))
  (expecting "catch"
    (expect ExceptionInfo (throw (ex-info "aw shucks" {}))))
  (expecting "spec"
    (expect ::pos 1)))
```
raw docstring

defexpectcljmacro

(defexpect n & body)

Adapted from expectations.clojure.test/defexpect.

Adapted from `expectations.clojure.test/defexpect`.
sourceraw docstring

expectcljmacro

(expect a)
(expect e a)
(expect e a msg)
(expect e a msg ex? e')

Adapted from expectations.clojure.test/expect.

Adapted from `expectations.clojure.test/expect`.
sourceraw docstring

expectingcljmacro

(expecting doc & body)

Adapted from expectations.clojure.test/expecting.

Adapted from `expectations.clojure.test/expecting`.
sourceraw docstring

from-eachcljmacro

(from-each bindings & body)

Adapted from expectations.clojure.test/from-each.

Adapted from `expectations.clojure.test/from-each`.
sourceraw docstring

incljmacro

(in coll)

Adapted from expectations.clojure.test/in.

Adapted from `expectations.clojure.test/in`.
sourceraw docstring

morecljmacro

(more & expecteds)

Adapted from expectations.clojure.test/more.

Adapted from `expectations.clojure.test/more`.
sourceraw docstring

more->cljmacro

(more-> & expected-threaded-pairs)

Adapted from expectations.clojure.test/more->.

Adapted from `expectations.clojure.test/more->`.
sourceraw docstring

more-ofcljmacro

(more-of destructuring & expected-actual-pairs)

Adapted from expectations.clojure.test/more-of.

Adapted from `expectations.clojure.test/more-of`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close