5

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?

Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115
  • Sigh. 3 days, no answers. I suspect this is impossible without modification to Cloverage itself: https://github.com/cloverage/cloverage/issues/54 – Bob Kuhar Dec 08 '17 at 23:50

1 Answers1

3

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
Philip
  • 4,128
  • 5
  • 31
  • 49
  • Extending this to multiple excluded namespaces is an exercise left to the reader :-D – Philip Jun 19 '18 at 15:27
  • Ended up having to exclude multiple namespaces. You can put anything inside the lookahead, so stuff like this works `#"^((?!(manual|integration)-test).)*$"` – Philip Jul 12 '18 at 22:49