gpt4 book ai didi

unit-testing - Clojure 测试框架的优势?

转载 作者:行者123 更新时间:2023-11-28 19:41:00 24 4
gpt4 key购买 nike

你更喜欢哪一个,为什么?各自的优缺点是什么?在哪种情况下,每个人都胜过其他人?

我对 midje 与 clojure.test 特别感兴趣,但也可以随意提出其他 Clojure 测试框架。

另见 Best unit testing framework for Clojure? (该问题的答案没有提供关于“为什么”的太多细节)。

最佳答案

我还没有全部尝试过,但我喜欢普通的 clojure.test原因如下:

  • 它已经存在于 Clojure API 中:没有额外的依赖。
  • 与 Maven 良好集成:我将 Eclipse 与 clojure-maven-plugin 结合使用,以确保在我构建时 Clojure 和 Java 测试都能自动运行。
  • 很简单:我在测试中需要的 99% 只是为了能够编写一组结构良好的断言,clojure.test 使这变得非常容易

示例代码:

(testing "Arithmetic"
(testing "with positive integers"
(is (= 4 (+ 2 2)))
(is (= 7 (+ 3 4))))
(testing "with negative integers"
(is (= -4 (+ -2 -2)))
(is (= -1 (+ 3 -4)))))

关于unit-testing - Clojure 测试框架的优势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7710877/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com