【发布时间】:2020-03-05 23:41:51
【问题描述】:
我正在尝试在 Clojure 上创建我的第一个测试。我写了this file。当我跑步时:
lein test
我明白了:
ERROR in (update-question) (core.clj:32)
Uncaught exception, not in assertion.
expected: nil
actual:
clojure.core/require core.clj: 6007 (repeats 2 times)
clojure.core/load-libs core.clj: 5969
clojure.core/load-libs core.clj: 5985
clojure.test/run-tests test.clj: 768 (repeats 2 times)
clojure.core/apply core.clj: 667
clojure.lang.ExceptionInfo: Parameter Mismatch: :id parameter data not found.
java.lang.Exception: Exception in :get-one-question
FAIL in (create-answer) (tests_test.clj:63)
Create a new answer
expected: (not (nil? (:ordnen answer)))
actual: (not (not true))
FAIL in (create-answer) (tests_test.clj:64)
Create a new answer
expected: nil
actual: "Some not so cool answer"
diff: + "Some not so cool answer"
2020-03-05 17:24:12,124 [main] INFO zentaur.models.tests-test - >>> PA @first-user @first-user >>>>> {:email "grayson@me.com", :fname "Grayson", :lname "Barr", :active true, :id 72, :role_id 1, :uuid "efc8c516-04f1-4b22-a983-ed1e9c4f0da7"}
Ran 5 tests containing 7 assertions.
**2 failures, 1 errors.**
Testing zentaur.models.tests-test
2020-03-05 17:24:12,233 [main] INFO zentaur.models.tests-test - >>> PARAM @first-question@first-question@first-question >>>>> {:explanation "Explanation", :reviewed_fact false, :question "Some cool Question", :points 2, :hint "Some hint", :qtype 2, :updated_at #time/instant "2020-03-05T23:24:12Z", :reviewed_cr false, :active true, :id 71, :user_id 1, :origin 0, :fulfill nil, :created_at #time/instant "2020-03-05T23:24:12Z", :reviewed_lang false}
2020-03-05 17:24:12,849 [main] INFO zentaur.models.tests-test - >>> PA @first-user @first-user >>>>> {:email "samantha@yahoo.com", :fname "Samantha", :lname "Good", :active true, :id 73, :role_id 1, :uuid "16d3eea4-3ed2-4636-a753-7fc0ec381e77"}
Ran 5 tests containing 8 assertions.
0 failures, 0 errors.
所以,看起来测试执行了两次,但第一次出错,第二次正确。我注意到这条线:
clojure.test/run-tests test.clj: 768 (repeats 2 times)
但我不知道为什么文件被调用两次以及为什么第一次“跳过”某些测试。如果我删除该行:
(run-tests)
从文件中,只执行第一次(也是错误的)时间。
【问题讨论】:
标签: clojure tdd clojurescript leiningen