1

Parts of my system are specced out really well, but when I change one of the predicates to be something obviously wrong I noticed all my tests still pass and I don't get the usual blowup from spec I've come to rely on.

I can't figure out why this is happening, and I certainly can't reproduce it starting from lein new test.

Is there a way I can get spec.test to give me a warning when it can't find a spec, for debug purposes, rather than assuming I didn't want to spec out this part of my system? Can it perhaps help me in some other way with debugging this situation?

4

2 回答 2

2

如果您尝试使用未定义的规范,规范应该会出错。

目前没有办法让它告诉你没有指定的事情。为此,需要检测(替换)所有变量并添加该检查。

对于您的特定问题,如果您有要更改的规范,我会搜索谁在使用该谓词,然后尝试测试使用这些规范或原始谓词的每个事物。

有时会让人绊倒的一件事是stest/instrument只检查:args函数的规格,而不是:retor:fn规格(仅由 使用stest/check)。

于 2016-12-22T15:20:11.513 回答
0

这是一个最小的复制:

(ns test.core
  (:require [clojure.spec :as s]))

(defn my-specced-fn [x]
  x)

(s/fdef my-specced-fn
        :args (s/cat :arg int?))

(ns test.core-test
  (:require [clojure
             [test :refer :all]]
            [test.core :as core]
            [clojure.spec.test :as spec-test]))

(spec-test/instrument)

(deftest my-specced-fn-test
  (is (= 1 (core/my-specced-fn 1))))

该测试最初通过。然后我会去编辑test.core,更改架构并重新评估test.core。在使用诸如测试之类的谓词更改架构后,string?应该会失败,但它会继续通过。要解决此问题,请重新评估测试名称空间(特别是对 的调用instrument)。

于 2016-12-22T16:41:31.327 回答