Liking cljdoc? Tell your friends :D

hegel-clj.clojure-test

Hegel integration with clojure.test.

Hegel integration with clojure.test.
raw docstring

capture-reportscljmacro

(capture-reports & body)

Evaluates body for clojure.test reports as a side effect. Returns a vector of those reports. In the final test phase, also sends those final reports to the normal clojure.test reporter.

Evaluates body for clojure.test reports as a side effect. Returns a vector
of those reports. In the final test phase, also sends those final reports to
the normal clojure.test reporter.
sourceraw docstring

originclj

(origin reports)

Produces an origin string for a set of reports. Hegel is... vague about what the origin should be; you don't want to be too specific or else it will explode the state space. I think just the file and line, perhaps?

Produces an origin string for a set of reports. Hegel is... vague about what
the origin should be; you don't want to be *too* specific or else it will
explode the state space. I think just the file and line, perhaps?
sourceraw docstring

pass?clj

(pass? reports)

Did every clojure.test report pass?

Did every clojure.test report pass?
sourceraw docstring

withcljmacro

(with opts bindings & body)

Can be embedded within a clojure.test deftest to generate some series of values and test whether they produce correct results. Takes an options map for hegel-clj.test/run-test!*, a binding vector, then a body. Evaluates body roughly test-cases times, with bindings provided by hegel-clj.gen/let. You can generate more values using gen or hegel-clj/let, if needed. Make test assertions using clojure.test/is, as usual. Failing tests will be automatically shrunk and re-run with minimal examples. Log these examples using fprn and friends, or when-final.

For example:

(deftest reverse-test
  ; Generate roughly a hundred integers of vectors
  (with {:test-cases 100, :seed 5}
        [xs (gen/vector (g/integer))]

    ; Print out only the smallest vectors that make this fail
    (fprn :xs xs)

    ; Is sorting the same as reversing? Clearly not, so this will fail,
    ; likely with a two-element vector of different numbers.
    (is (= (sort xs)
        (reverse xs)))))

with suppresses clojure.test reporting until the final phase, where it reports as normal. You can broadly pretend that this is a clojure.test case where you just happened to guess the right small inputs to reproduce a failing bug.

Can be embedded within a clojure.test deftest to generate some series of
values and test whether they produce correct results. Takes an options map
for `hegel-clj.test/run-test!*`, a binding vector, then a body. Evaluates
body roughly `test-cases` times, with bindings provided by
`hegel-clj.gen/let`. You can generate more values using `gen` or
`hegel-clj/let`, if needed. Make test assertions using `clojure.test/is`, as
usual. Failing tests will be automatically shrunk and re-run with minimal
examples. Log these examples using `fprn` and friends, or `when-final`.

For example:

    (deftest reverse-test
      ; Generate roughly a hundred integers of vectors
      (with {:test-cases 100, :seed 5}
            [xs (gen/vector (g/integer))]

        ; Print out only the smallest vectors that make this fail
        (fprn :xs xs)

        ; Is sorting the same as reversing? Clearly not, so this will fail,
        ; likely with a two-element vector of different numbers.
        (is (= (sort xs)
            (reverse xs)))))

`with` suppresses clojure.test reporting until the final phase, where it
reports as normal. You can broadly pretend that this is a clojure.test case
where you just happened to guess the right small inputs to reproduce a
failing bug.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close