简体   繁体   中英

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]
        [pcc.core :refer :all]
        [midje.sweet :refer :all]))

(println "You should expect to see one failure below.")

(facts
 "About miscellaneous functions"
 (fact
  "Returns a zero padded string representation of integer"
  (zero-pad 1 4) => "0001"
  (zero-pad 15111 4) => "15111"
  (zero-pad 2 5) => "00002")

 (fact
  "Returns a path stripped of extension, if any"
  (strip-file-ext "/alfa/bravo/charlie.dat") => "/alfa/bravo/charlie"
  (strip-file-ext "/alfa/bravo/charlie") => "/alfa/bravo/charlie"
  (strip-file-ext "/alfa/bravo/charlie/") => "/alfa/bravo/charlie"
  (strip-file-ext "/alfa/bra.vo/charlie.dat") => "/alfa/bra.vo/charlie"))

The output of lein test :

$ lein test
You should expect to see one failure below.

FAIL "About miscellaneous functions - Returns a path stripped of extension, if any" at (core_test.clj:24)
  Expected: "/alfa/bravo/charlie"
    Actual: "/alfa/bravo/charlie/"
You should expect to see one failure below.

FAIL "About miscellaneous functions - Returns a path stripped of extension, if any" at (core_test.clj:24)
Expected: "/alfa/bravo/charlie"
  Actual: "/alfa/bravo/charlie/"

lein test user

Ran 0 tests containing 0 assertions.
0 failures, 0 errors.
$

It just runs twice. Curiously, the basic lein new midje project runs once, but I can see no substantial difference.

As per https://github.com/marick/Midje/wiki/A-tutorial-introduction midje is intended to run test through lein midje command rather than lein test .

From the code you pasted you didn't need the [clojure.test :refer :all] on your require

To create a new midje test suite the correct command is lein new midje <<projectname>> not sure if you simply closed the bold tag prematurely on your post though

Hope it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM