2014-12-05 64 views
0

我只是在一些項目上玩midje。 core_test.clj:Clojure,midje:lein測試 - 運行兩次

(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")) 

雷音測試的輸出:

$ 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. 
$ 

它只是運行兩次。奇怪的是,基本的項目運行一次,但我看不到實質性的差異。

+0

你得到了運行「lein midge」相同的結果嗎? – 2014-12-05 21:09:10

+0

我發現了一些東西,至少(不到一半的答案):你的** test **目錄下必須只有一個文件(core_test.clj)。很高興知道爲什麼。 – 2014-12-06 06:36:13

回答

0

根據https://github.com/marick/Midje/wiki/A-tutorial-introduction midje打算通過lein midje命令運行測試而不是lein test

從你粘貼你並不需要在[clojure.test :refer :all]代碼你require

要創建一個新midje測試套件正確的命令是lein new midje <<projectname>>不知道,如果你簡單地關閉了大膽的標籤過早您的文章雖然

希望它有幫助