Git Product home page Git Product logo

cloverage's Introduction

cloverage

Simple clojure coverage tool.

Travis: Build Status

CircleCI: CircleCI

Installation

Add Clojars Project to :plugins in your .lein/profiles.clj

Testing frameworks support

Cloverage uses clojure.test by default. If you prefer use midje, pass the --runner :midje flag. (In older versions of Cloverage, you had to wrap your midje tests in clojure.test's deftest. This is no longer necessary.) Other test libraries may ship with their own support for Cloverage external to this library; see their documentation for details.

Usage

lein

Run lein cloverage in your project. See cloverage/coverage.clj for more options.

To specify the version of cloverage manually, set the CLOVERAGE_VERSION to desired value, for example CLOVERAGE_VERSION=1.0.4-SNAPSHOT lein cloverage

By default, the plugin will use the latest release version of cloverage.

Leiningen project options

You can set project default settings for Cloverage in your project. Command line arguments can still be used and will be merged in. List options are merged by concatenation, for other options the project value is used.

Available options and command-line arguments:

 Project           Switches                     Default          Desc
 -------           --------                     -------          ----
 :output           -o, --output                 target/coverage  Output directory.
 :text?            --no-text, --text            false            Produce a text report.
 :html?            --no-html, --html            true             Produce an HTML report.
 :emma-xml?        --no-emma-xml, --emma-xml    false            Produce an EMMA XML report. [emma.sourceforge.net]
 :lcov?            --no-lcov, --lcov            false            Produce a lcov/gcov report.
 :codecov?         --no-codecov, --codecov      false            Generate a JSON report for Codecov.io
 :coveralls?       --no-coveralls, --coveralls  false            Send a JSON report to Coveralls if on a CI server
 :junit?           --no-junit, --junit          false            Output test results as junit xml file. Supported in :clojure.test runner
 :raw?             --no-raw, --raw              false            Output raw coverage data (for debugging).
 :summary?         --no-summary, --summary      true             Prints a summary
 :fail-threshold   --fail-threshold             0                Sets the percentage threshold at which cloverage will abort the build. Default: 0%
 :low-watermark    --low-watermark              50               Sets the low watermark percentage (valid values 0..100). Default: 50%
 :high-watermark   --high-watermark             80               Sets the high watermark percentage (valid values 0..100). Default: 80%
 :debug?           -d, --no-debug, --debug      false            Output debugging information to stdout.
 :runner           -r, --runner                 :clojure.test    Specify which test runner to use. Built-in runners are `clojure.test` and `midje`.
 :nop?             --no-nop, --nop              false            Instrument with noops.
 :ns-regex         -n, --ns-regex               []               Regex for instrumented namespaces (can be repeated).
 :ns-exclude-regex -e, --ns-exclude-regex       []               Regex for namespaces not to be instrumented (can be repeated).
 :test-ns-regex    -t, --test-ns-regex          []               Regex for test namespaces (can be repeated).
 :src-ns-path      -p, --src-ns-path            []               Path (string) to directory containing source code namespaces (can be repeated).
 :test-ns-path     -s, --test-ns-path           []               Path (string) to directory containing test namespaces (can be repeated).
 :extra-test-ns    -x, --extra-test-ns          []               Additional test namespace (string) to add (can be repeated).
 :custom-report    -c, --custom-report                           Load and run a custom report writer. Should be a namespaced symbol. The function is passed
    project-options args-map output-directory forms
 :help?            -h, --no-help, --help        false            Show help.

mvn

There is no maven plugin right now. A workaround is to import this library in the project being tested, then run: mvn exec:java -Dexec.classpathScope=test -Dexec.mainClass='clojure.main' -Dexec.args='--main cloverage.coverage *args-to-coverage*'

Where args-to-coverage will usually be something like "-n 'ns.regex.' -t 'text.ns.regex.'"

Troubleshooting

IllegalArgumentException No matching field found: foo for class user.Bar

IllegalArgumentException No matching field found: foo for class user.Bar  clojure.lang.Reflector.getInstanceField (Reflector.java:271)

This is usually caused by protocols with methods starting with -. Before clojure 1.6:

user=> (defprotocol Foo (-foo [x] x))
Foo
user=> (deftype Bar [] Foo (-foo [_] "foo"))
user.Bar
user=> (-foo (Bar.))
"foo"
user=> ((do -foo) (Bar.))

IllegalArgumentException No matching field found: foo for class user.Bar  clojure.lang.Reflector.getInstanceField (Reflector.java:271)

Since cloverage will wrap the -foo symbol to track whether it's accessed, you will get this error. Upgrade to clojure 1.6.

Coverage reports 0% coverage after running tests

This happens if there is a namespace in your project that requires itself, for example:

(ns foo.bar
  (:require [foo.bar :as bar]))

Remove the self-reference and the test coverage report should report correctly again.

License

Distributed under the Eclipse Public License, the same as Clojure.

Contributors

  • 2015 LShift, Tom Parker
  • 2012 LShift, Jacek Lach, Alexander Schmolck, Frank Shearar
  • 2010 Michael Delaurentis

Mentions

Some code was taken from

  • Java IO interop (clojure-contrib/duck-streams) by Stuart Sierra (see cloverage/source.clj)
  • Topological sort (https://gist.github.com/1263783) by Alan Dipert (see cloverage/kahn.clj)

cloverage's People

Contributors

lvh avatar palfrey avatar jaceklach avatar rm-hull avatar aschmolck avatar frankshearar avatar gonewest818 avatar davidjameshumphreys avatar rfkm avatar michaelblume avatar drazisil avatar dlobue avatar minleychris avatar bfontaine avatar baghdasaryan avatar cichli avatar philipa avatar jarnovayrynen avatar naiquevin avatar samestep avatar technomancy avatar emlyn avatar aeronotix avatar minutetominute avatar timofreiberg avatar tanzoniteblack avatar ryfow avatar ricardojmendez avatar brabster avatar nwjsmith avatar

Watchers

赖泳钦 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.