Liking cljdoc? Tell your friends :D

me.pmatiello.mockfn.clj-test


deftestcljmacro

(deftest name & body)

Declares a test function as done by clojure.test/deftest with built-in support for mocking through (optional) providing and verifying forms.

(deftest test-name
  ; test code
  (providing
    ; one or more entries in the form:
    ; (fn-name &args) return-value
    ...)
  (verifying
    ; one or more entries in the form:
    ; (fn-name &args) return-value call-count-matcher
    ...)

Example:

(deftest test-name
  (is (= :ret-val (one-fn)))
  (providing
    (one-fn) :ret-val))
Declares a test function as done by `clojure.test/deftest` with built-in
support for mocking through (optional) `providing` and `verifying` forms.

```
(deftest test-name
  ; test code
  (providing
    ; one or more entries in the form:
    ; (fn-name &args) return-value
    ...)
  (verifying
    ; one or more entries in the form:
    ; (fn-name &args) return-value call-count-matcher
    ...)
```

Example:
```
(deftest test-name
  (is (= :ret-val (one-fn)))
  (providing
    (one-fn) :ret-val))
```
sourceraw docstring

invokeclj

(invoke func)

Marks a function to be dynamically invoked on mock calls. Matching calls will invoke the function with the received arguments and return the output.

Example:

(deftest test-name
  (is (= :invoke-fn (one-fn :invoke-fn)))
  (providing
    (one-fn :invoke-fn) (invoke identity)))
Marks a function to be dynamically invoked on mock calls. Matching calls
will invoke the function with the received arguments and return the output.

Example:
```
(deftest test-name
  (is (= :invoke-fn (one-fn :invoke-fn)))
  (providing
    (one-fn :invoke-fn) (invoke identity)))
```
sourceraw docstring

providingclj

source

raiseclj

(raise exception)

Creates a mock behavior that throws the given exception when the mock is called.

This can be used to simulate error scenarios in tests by configuring a mock to throw a specific exception.

Example:

(deftest raise-test
  (is (thrown? ExceptionInfo (f/one-fn)))
  (providing
    (f/one-fn) (raise (ex-info "error!" {}))))
Creates a mock behavior that throws the given exception when the mock is called.

This can be used to simulate error scenarios in tests by configuring a mock
to throw a specific exception.

Example:
```
(deftest raise-test
  (is (thrown? ExceptionInfo (f/one-fn)))
  (providing
    (f/one-fn) (raise (ex-info "error!" {}))))
```
sourceraw docstring

testingcljmacro

(testing string & body)

Declares a new testing context inside a test function as done by clojure.test/testing with built-in support for mocking through (optional) providing and verifying forms.

(testing "description"
  ; test code
  (providing
    ; one or more entries in the form:
    ; (fn-name &args) return-value
    ...)
  (verifying
    ; one or more entries in the form:
    ; (fn-name &args) return-value call-count-matcher
    ...)

Example:

(deftest test-name
  (testing "context"
    (is (= :ret-val (one-fn)))
    (verifying
      (one-fn) :ret-val (mockfn.matchers/exactly 1))))
Declares a new testing context inside a test function as done by
`clojure.test/testing` with built-in support for mocking through (optional)
`providing` and `verifying` forms.

```
(testing "description"
  ; test code
  (providing
    ; one or more entries in the form:
    ; (fn-name &args) return-value
    ...)
  (verifying
    ; one or more entries in the form:
    ; (fn-name &args) return-value call-count-matcher
    ...)
```

Example:
```
(deftest test-name
  (testing "context"
    (is (= :ret-val (one-fn)))
    (verifying
      (one-fn) :ret-val (mockfn.matchers/exactly 1))))
```
sourceraw docstring

verifyingclj

source

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

× close