我正在测试一个函数,以确保它调用另一个命名空间中的函数。我想将函数存根(使用散斑存根),这样我就可以记录调用。
(defn fn-under-test []
(p/helper-fn))
(describe "test"
(with-stubs)
(around [it]
(with-redefs [p/helper-fn (stub :helper)]
(it)))
(it "should call the helper-fn"
(fn-under-test)
(should-have-invoked :helper {:times 1})))我有个例外:
java.lang.Exception: Stub recoding not bound. Please add (with-stubs) to the decribe/context.如果在当前命名空间中定义了helper-fn,则一切都按预期工作。如何使用speclj在另一个名称空间中存根函数?
编辑:当从不同的线程调用存根函数时,就会发生异常。我创建了一个拉请求来解决这个问题。
发布于 2014-11-24 03:54:20
我对您的示例进行了编码,规范运行良好;通过时没有出错。我想不出为什么fns在另一个名称空间中不能工作。我一直都这么做。
下面是展示我工作的要点:https://gist.github.com/slagyr/2aed1ccfd8ec702d7051
https://stackoverflow.com/questions/27080974
复制相似问题