【问题标题】:Exclude tests with a specific selector in lein test在 lein 测试中排除具有特定选择器的测试
【发布时间】:2022-12-24 11:20:33
【问题描述】:

我在基于 leiningen 的 Clojure 项目中有一套测试。

我想跑最多他们经常,但我想排除那些带有 :integration 选择器的,因为它们速度慢且不稳定。

如果我理解正确的话,leiningen 中有一个内置的 :only 选择器,它将只运行匹配的测试:

lein test :only :integration

我想要一个 :not 选择器,它做相反的事情(运行除 :integration 之外的所有选择器)。

lein test :not :integration

有没有办法用 lein test 提供的设施来构建它?

我知道我可以写一个像 (complement :integration) 这样的 fn,然后把它放在我的 project.clj:test-selectors 映射中,但是它会被硬编码为忽略 :integration——我真正想要的是一个通用的 :not我可以用关键字参数化,所以我可以在其他情况下忽略我的 :slow:flaky 测试。

【问题讨论】:

    标签: testing clojure leiningen


    【解决方案1】:

    我不认为你可以用关键字来做到这一点,因为 Leiningen 将它们作为参数。但是您可以创建一个传递字符串的自定义测试选择器:

    :test-selectors {:not (fn [m s] (not (contains? m (keyword s))))}
    

    您可以使用lein test :not integrationlein test :not flaky 进行呼叫。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-28
      • 1970-01-01
      • 1970-01-01
      • 2012-11-25
      • 1970-01-01
      • 2017-12-28
      • 2012-07-11
      • 1970-01-01
      相关资源
      最近更新 更多