Search code examples
clojureleiningen

Can I make lein cloverage skip specific tests?


I'm on a Leiningen project that has its integration tests annotated like...

(deftest ^:manual test-v3-preview
  (preview-client "http://localhost:10313/v3/preview"))

These tests always fail when I lein cloverage. Are there arguments I can pass to lein cloverage that skips the ^manual tests?


Solution

  • As of cloverage 1.0.11 (currently unreleased) you can specify a :test-ns-regex option. See documentation in the README.

    Using a negative lookahead regex you can run all namespaces that do not contain the string in the lookahead. E.g.

    #"^((?!manual-test).)*$"
    

    Here is a full example since I spent way too long figuring out how to do this. You also need to specify the cloverage version as an environment variable because otherwise it uses the latest released version.

    In project.clj:

    :profiles
     {:cloverage  {:plugins [[lein-cloverage "1.0.11-20180518.155437-26"]]
                   :cloverage {:test-ns-regex [#"^((?!manual-test).)*$"]}}}
    

    Then to run it:

    CLOVERAGE_VERSION=1.0.11-20180518.155428-32 lein with-profile +test,+cloverage cloverage