Spacemacs Cider测试不会失败

Erw*_*ers 1 emacs clojure cider spacemacs clojure.test

当我使用Clojure模式在Spacemacs中运行测试<SPC> m t t时,即使测试明显失败,也不会显示失败.看到:

测试不会失败

1不等于2,但仍有0次测试失败.

如何让测试失败?

Pio*_*dyl 5

您的测试中存在一个问题:它缺少比较运算符.正确的版本是:

(deftest test-exercise-1-4
  (testing "count-anywhere"
    (is (= 2 1))))
Run Code Online (Sandbox Code Playgroud)

is 宏具有以下定义(为简洁而编辑的源代码):

(defmacro is
  "Generic assertion macro.  'form' is any predicate test.
  'msg' is an optional message to attach to the assertion.

  Example: (is (= 4 (+ 2 2)) \"Two plus two should be 4\")

  ([form] `(is ~form nil))
  ([form msg] `(try-expr ~msg ~form)))
Run Code Online (Sandbox Code Playgroud)

正如你所看到的那样,(is 2 1)你正在调用第二个arity,其中formis 2和assertion的消息是1.正如2那样,它使断言通过:

(is 2)
;; => 2

(is false)

FAIL in () (boot.user5045373352931487641.clj:1)
expected: false
  actual: false
;; => false
Run Code Online (Sandbox Code Playgroud)