使用測試巨集對相關測試進行分組
你可以使用 testing
巨集在上下文中對 deftest
單元測試中的相關斷言進行分組:
(deftest add-nums
(testing "Positive cases"
(is (= 2 (+ 1 1)))
(is (= 4 (+ 2 2))))
(testing "Negative cases"
(is (= -1 (+ 2 -3)))
(is (= -4 (+ 8 -12)))))
這有助於在執行時澄清測試輸出。請注意,testing
必須出現在 deftest
內。