Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Test helper functions, including an all clojure mocking facility

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 pom.xml
Octocat-spinner-32 project.clj
README.md

Atticus

atticus is a embryonic collection of tools to help testing.

atticus.mock is a slightly different approach to mocking, where the mocked function can be implemented as an inline function to do whatever checking or return value calculation that is required.

;; pull in namespaces
    (use 'clojure.test)
    (require 'atticus.mock)

;; define test which mocks f
(deftest mock-test
      (atticus.mock/expects
        [(f [arg]
           (is (= arg 1) "Check argument")
           arg)]
    (is (= 1 (f 1)) "Call mocked function"))

At the moment there are two macros that can be used to wrap the body of the mocked function and will add verification for the number of times the mocked function is called. The once macro ensures the function is called once, and only once. The times macro, which takes an integer argument, ensures the function is called exactlyt he specified number of times.

;; define test, that should be called just once
(deftest mock-test
      (atticus.mock/expects
        [(f [arg]
           (atticus.mock/once
             (is (= arg 1) "Check argument")
             arg))]
    (is (= 1 (f 1)) "Call mocked function"))

atticus.utils contains some test helpers for accessing private vars, and for handling temporary files.

API documentation is available.

Installation

atticus is distributed as a jar, and is available in the clojars repository.

Installation is with Leiningen, maven, or your favourite maen repository aware build tool.

License

Licensed under EPL

Something went wrong with that request. Please try again.