mockfn

A library for mocking Clojure functions.


Keywords
clojure, mocking, test-driven-development, testing
License
EPL-1.0

Documentation

mockfn

mockfn is a library supporting mockist test-driven-development in Clojure. It is meant to be used alongside a regular testing framework such as clojure.test.

Clojars Project

CircleCI

Usage

The providing macro replaces a function with a configured mock.

(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.

(deftest verifying-test
  (verifying
    [(one-fn) :mocked (at-least 1)]
    (is (= :mocked (one-fn)))))

Refer to the documentation for more detailed information, including:

License

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.