(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))
```(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)))
```(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 (one-fn)))
  (providing
    (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 (one-fn)))
  (providing
    (one-fn) (raise (ex-info "error!" {}))))
```(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))))
```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 |