Skip to content

Latest commit

 

History

History
180 lines (128 loc) · 4.76 KB

README.md

File metadata and controls

180 lines (128 loc) · 4.76 KB

eftest-coverage

Clojars Project

A tiny wrapper around Eftest Clojure test runner for getting test coverage using Cloverage instrumentation.

DISCLAIMER: probably you should use a native way to run Cloverage with Eftest instead of this lib.

Installation

project.clj :dependencies

[abogoyavlensky/eftest-coverage "0.1.1"]

deps.edn :deps

abogoyavlensky/eftest-coverage {:mvn/version "0.1.1"}

Usage examples

Run directly (configurable Eftest)

deps.edn with -M option

{
 ...
 :aliases {:test
           {:extra-paths ["test"]
            :extra-deps {abogoyavlensky/eftest-coverage {:mvn/version "VERSION"}}
            :main-opts   ["-m" "eftest-coverage.runner"
                          "-p" "src"
                          "-s" "test"]}}}

Then run:

clojure -M:test

Run via Cloverage (only default settings for Eftest)

Running via Cloverage you don't have ability to configure the Eftest runner. Just run Eftest with coverage as is with default settings. Cloverage's configuration is fully available in both cases.

deps.edn

{...
 :aliases {:test
           {:extra-paths ["test"]
            :extra-deps {abogoyavlensky/eftest-coverage {:mvn/version "VERSION"}}
            :main-opts   ["-m" "cloverage.coverage"
                          "-p" "src"
                          "-s" "test"
                          "--runner" ":eftest-coverage"]}}}
clojure -M:test

project.clj

{...
 [[abogoyavlensky/eftest-coverage "VERSION"]]
 :plugins [[lein-cloverage "1.2.1"]]
 ...
}
lein cloverage --runner :eftest-coverage

Configuration

Cloverage options

All options for Cloverage available exactly as in origin library. The runner option has reasonable default value:

--runner :eftest-coverage

Eftest options

All options for Eftest are available exactly as in origin library with prefix --eftest-...:

Option Value Default
--eftest-fail-fast? false, true false
--eftest-capture-output? false, true true
--eftest-multithread? true, false, :namespaces, :vars true
--eftest-thread-count int number > 0 calculated if --eftest-multithread? is enabled
--eftest-randomize-seed int number >= 0 0
--eftest-report path to report function eftest.report.progress/report
--eftest-test-warn-time int time in milliseconds nil

ℹ️ Keeping Eftest's semantic of boolean options with ? sign at the end to have full compatibility with origin library.

eftest-coverage extra options

Also eftest-coverage has a couple extra options for convenience.

Option Value Default Description
--eftest-report-to-file path to a file nil Redirect Eftest reporting output to a file.
--[no-]coverage boolean flag --coverage Run test runner without coverage instrumenting. (enabled by default)

Config example with some eftest options

deps.edn

{...
 :aliases {:test
           {:extra-paths ["test"]
            :extra-deps {abogoyavlensky/eftest-coverage {:mvn/version "VERSION"}}
            :main-opts   ["-m" "eftest-coverage.runner"
                          "-p" "src"
                          "-s" "test"
                          "--eftest-test-warn-time" "100"
                          "--eftest-multithread?" "false"
                          "--eftest-fail-fast?" "true"
                          "--eftest-report" "eftest.report.junit/report"
                          "--eftest-report-to-file" "target/eftest/junit.xml"]}}}

Development

Build a deployable jar of this library:

$ make build

Install it locally:

$ make install

Deploy it to Clojars. Needs CLOJARS_USERNAME and CLOJARS_PASSWORD environment variables:

$ make deploy

Heavily inspired by

Roadmap

  • Add ability to use -X option of Clojure CLI.
  • Add lein-eftest-coverage plugin with ability to configure Eftest runner. Use cloverage/run-project instead.
  • Add ability to configure :only and metadata selectors for particular tests.

License

Copyright © 2020 Andrey Bogoyavlensky

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.