Hopefully the code is what you'd expect.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns success.success-examples | |
(:use expectations erajure.core)) | |
;; mock interaction based testing | |
(expect-let [r (mock Runnable)] | |
(interaction (.run r)) | |
(.run r)) |
The previous example creates a mock Runnable in an expect-let, expects the
run
method to be run, and then calls the run method of the mock. This test is worthless in a real world context, but it's the simplest way to demonstrate the syntax for creating a mock & specifying the interaction.
The
mock
function defined in erajure, a minimal wrapper around mockito. All of the "times" arguments are the same as what's available for function interaction tests, examples can be found here.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.