Questions tagged [midje]

Midje is a unit test framework for Clojure.

60 questions
1
vote
2 answers

Midje provided not stubbing function in Compojure / Ring handler

I'm attempting to use Midje to stub the view in a handler unit test, but my use of Midje's (provided) obviously isn't correct. I've simplified and inlined the view to a (content) function in the handler: (ns whattodo.handler (:use…
Paul Williams
  • 386
  • 7
  • 20
1
vote
1 answer

Midje print stacktrace when test fails

I am learning Clojure, and trying to use TDD to do so *. I use midje as a testing library. Love it so far, the expected versus actual results display is very helpfull. But is there was a way to use clojure.tools.trace or something similar to print…
nha
  • 17,623
  • 13
  • 87
  • 133
1
vote
2 answers

Faking friend credential function using Midje

I'm trying to test my routing in isolation using Midje. For some routes that hit the database I have no trouble using (provided ...) to isolate the route from a real db call. I've introduced Friend for authentication and I've been unable to fake the…
Hugo
  • 710
  • 1
  • 10
  • 19
1
vote
1 answer

Clojure/Midje using AOT compilation with tests inside source fails to run

I'm trying to include midje "facts" alongside my source code in a project which uses aot. Trying to access the repl or run the project results in the following error, I've included a minimal sample project which reproduces the issue. Thanks for any…
Matt
  • 746
  • 6
  • 16
1
vote
1 answer

How do I test futures in clojure?

I'm trying to use midje to test a future, but I can't seem to get it to work. The code looks like (defn foo [] (let [f (future (bar))] (baz @f)) With a test like (fact (foo) => ..a.. (provided (bar) => ..b.. (baz ..b..) =>…
aciniglio
  • 1,777
  • 1
  • 16
  • 18
1
vote
2 answers

Mocking protocol implementations in Midje

Is there any way to mock (not stub) a protocol function with Midje (clojure) using something like the "provided" syntax? This is simial to the question in: Mocking Clojure protocols, but with mocking. In more detail: I have a protocol and a…
4ZM
  • 1,463
  • 1
  • 11
  • 21
1
vote
2 answers

Dynamically calculated description of a midje fact

I want to write a function to factor out some common facts, like this (defn check-odd-and-positive [n] (fact (str n " not odd") n => odd?) (fact (str n " not positive") n => positive?)) (facts "about the answer" (check-odd-and-positive…
Adam Schmideg
  • 10,590
  • 10
  • 53
  • 83
0
votes
1 answer

Midje: having single actual value with multiple arrow functions

Put simply, I would like the code shown below to behave how one could think it should behave, e.g. defining the left-hand side value (here as a trivial anonymous associative collection) just once and applying multiple different arrow functions…
Michal M
  • 1,521
  • 14
  • 35
0
votes
1 answer

Kaocha-midje setup

We have a load of midje tests setup for Clojure, they currently work with lein midje. We want to use Kaocha-midje, and then the rest of kaocha, but cannot get any tests to be found using Kaocha.type/midje. Heres the project.clj add-ins: :profiles…
f1wade
  • 2,877
  • 6
  • 27
  • 43
0
votes
1 answer

clojure testing using midge

My function accepts a map argument in which i get the deposit value from it. Currently I'm able to test scenarios like whether the deposit value is empty or whether the deposit value is greater than a certain value etc. My API tracks the number of…
G. Joe
  • 53
  • 2
  • 15
0
votes
1 answer

Inconsistent results when testing a chan processing function

The process-async function tested within the midje framework produces inconsistent results. Most of the time it checks as expected, but from time to time, it reads out.json at its initial state (""). I rely on the async-blocker function to wait on…
user3639782
  • 487
  • 3
  • 10
0
votes
1 answer

JUnit AfterClass equivalent in Midje Clojure?

I could not find any Midje function that runs after all facts. Here is the code: (background (before :contents (println "Before All Facts")) (after :contents (println "After All Facts")) (before :facts (println "Before Each Fact")) (after…
Ertuğrul Çetin
  • 5,131
  • 5
  • 37
  • 76
0
votes
1 answer

FileNotFound exception while running Midje tests

I have a Leiningen project which uses Midje library for testing. Howerver I am not able to run any tests, in case of lein test I get java.io.FileNotFoundException: Could not locate midje/sweet__init.class or midje/sweet.clj on classpath Or…
Petr Mensik
  • 26,874
  • 17
  • 90
  • 115
0
votes
2 answers

Halting a program at a debug point?

I am using emacs for clojure development. So after using: C-u M-x cider-jack-in (in my test file). Followed by lein repl followed by M-x cider-connect I get a strange, partially working repl at the root of my project where I have to provide the…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
0
votes
1 answer

Midje stub method doesn't work

I'm trying to do this: (defn pilot-ready [args] [2]) (defn ready [] (pilot-ready ["hello"])) (facts (ready) => [1] (provided (pilot-ready ["hello"]) => [1])) (against-background [(pilot-ready ["hello"]) => [1]] (fact (ready) =>…
Danix
  • 1,947
  • 1
  • 13
  • 18