https://github.com/nubank/mockfn
A mocking library for Clojure.
https://github.com/nubank/mockfn
nubank-stable
Last synced: 9 months ago
JSON representation
A mocking library for Clojure.
- Host: GitHub
- URL: https://github.com/nubank/mockfn
- Owner: nubank
- License: epl-1.0
- Created: 2020-03-18T13:28:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-15T18:32:33.000Z (over 1 year ago)
- Last Synced: 2025-03-29T21:07:55.846Z (10 months ago)
- Topics: nubank-stable
- Language: Clojure
- Homepage:
- Size: 96.7 KB
- Stars: 88
- Watchers: 355
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# mockfn
[`mockfn`](https://github.com/pmatiello/mockfn) is a Clojure(script) library
supporting mockist test-driven-development in Clojure. It is meant to be used
alongside a regular testing framework such as `clojure.test`.
[](https://clojars.org/nubank/mockfn)
## Usage
The `providing` macro replaces a function with a configured mock.
```clj
(deftest providing-test
(providing
[(one-fn) :mocked]
(is (= :mocked (one-fn)))))
```
The `verifying` macro works similarly, but also defines an expectation
for the number of times a call should be performed during the test.
```clj
(deftest verifying-test
(verifying
[(one-fn) :mocked (at-least 1)]
(is (= :mocked (one-fn)))))
```
Refer to the [documentation](doc/documentation.md) for more detailed
information, including:
- [Framework-agonostic usage](doc/documentation.md#framework-agonostic-usage)
- [Syntax sugar for `clojure.test`](doc/documentation.md#syntax-sugar-for-clojuretest)
- [Argument matchers](doc/documentation.md#argument-matchers)
## License
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.