Midje is a unit test framework for Clojure.
Questions tagged [midje]
60 questions
2
votes
1 answer
How to test Exception being thrown with midje
Simple question. I'm trying to test in midje if my method triggers an exception. I could only find something like the following in the midje documentation.
(fact "Should throw a RuntimeException"
(my-method! anything) =throws=>…

Neikon
- 169
- 1
- 10
2
votes
1 answer
Is there an equivalent of Midje facts form in clojure.test?
(facts ...) form in Midje, let's us group a bunch of (fact ..) forms and also have more (facts ..) form under it.
When writing corresponding test suite in clojure.test, what should be used to replace, (facts ...) ? Is there something else in…

Amogh Talpallikar
- 12,084
- 13
- 79
- 135
2
votes
1 answer
How to skip Clojure Midje tests
If I have a Clojure test suite written using the Midje testing framework, how do I skip individual tests? For example, if I were using JUnit in Java and I wished to skip a single test, I would add an @Ignore attribute above that test method. Is…

Neikon
- 169
- 1
- 10
2
votes
1 answer
For loop not working inside midje test?
Found some odd behavior in midje, not sure if it's midje related, or due to my misunderstanding of some clojure constructs, but it's puzzling:
Inside a facts statement, a for loop is not getting called:
(ns t1
(:require [midje.sweet :refer :all ]…

Steve B.
- 55,454
- 12
- 93
- 132
2
votes
1 answer
Clojure, midje: lein test - running twice
I'm just toying with midje on some project. core_test.clj:
(ns pcc.core-test
(:use [clojure.repl])
(:require [clojure.test :refer :all]
[clojure.string :as string]
[green-tags.core :as core]
[me.raynes.fs :as fs]
…

Alexey Orlov
- 2,412
- 3
- 27
- 46
2
votes
1 answer
Testing filesystem code
Unit-testing with Midje is a great experience, but now I need to test some code which interacts with the filessytem. Specifically, the code builds a data structure representation from a local directory layout.
Something that comes to mind is…

jforberg
- 6,537
- 3
- 29
- 47
2
votes
1 answer
Run tests from a single namespace using clojure and midje 1.4.0
I want to call my midje 1.4.0 unit tests from one namespace from a clojure repl without leiningen.
The background is I want to call them from a shortcut in vim without all the other tests in the project. I am using vimclojure-static and…

Benjamin Peter
- 4,009
- 2
- 23
- 23
2
votes
1 answer
Setup and teardown temporary directory for a midje fact
This is the skeleton of what I want to achieve
(let [temp-dir (create-temp-dir)] ; setup
(fact
(do-something-with temp-dir) => true) ; actual test
(delete-dir temp-dir)) ; teardown
The midje testing framework…

Adam Schmideg
- 10,590
- 10
- 53
- 83
1
vote
1 answer
Midje, provided not working as I expect
I have written the following Midje test:
(fact (followers-minus-friends ...name...) => ["Dude"]
(provided (idset show-followers ...name...) => #{1 2 3}
(idset show-friends ...name...) => #{1 2}
(userinfos #{3})…

Michiel Borkent
- 34,228
- 15
- 86
- 149
1
vote
1 answer
Is it common for people to test their clojure.spec specs?
I'm learning Clojure, all by myself and I've been working on a simple toy project to create a Kakebo (japanese budgeting tool) for me to learn. First I will work on a CLI, then an API.
Since I'm just begining, I've been able to "grok" specs, which…

George Silva
- 3,454
- 10
- 39
- 64
1
vote
0 answers
Unable to mock HugSQL generated database functions with Midje
I'm having a problem mocking database access functions generated from HugSQL templates with the Conman helper library. These functions are defined at runtime like this:
(conman/bind-connection *db* file)
In my case, I'm unit testing this service…

Kristian Salo
- 350
- 3
- 9
1
vote
1 answer
Test pre-requisites for tabular tests; how does tabular work?
Let's say I am attempting to test an api that is supposed to handle presence or absence of certain object fields.
Let's say I have tests like so:
(def without-foo
{:bar "17"})
(def base-request
{:foo "12"
:bar "17"})
(def without-bar
…

Abraham P
- 15,029
- 13
- 58
- 126
1
vote
1 answer
mocking a function call in midje
Say I have a function
(defn extenal_api_fn [stuff]
... do things....
)
(defn register_user [stuff]
(external_api_fn stuff))
And then a test
(def stuff1
{:user_id 123 })
(def stuff2
{:user_id 234})
(background (external_api_fn stuff1) =>…

Abraham P
- 15,029
- 13
- 58
- 126
1
vote
1 answer
midje does not stub functions provided with hashmaps
Consider the following code
(use 'midje.sweet) …

user3639782
- 487
- 3
- 10
1
vote
1 answer
midje - how to expect different results for two identical function calls (including exception to be throwed)
I have implemented retry policy for update function (talking to database) - if update throws exception I retry it up to 10 times. I am mocking the update function with midje. I want to simulate that first time it fails and second time it succeeds. I…

Viktor K.
- 2,670
- 2
- 19
- 30