Coder Social home page Coder Social logo

cobertura_cover's Introduction

CoberturaCover

A plugin for mix test --cover that writes a coverage.xml file compatible with Jenkins' Cobertura plugin.

Inspired by covertool for Erlang.

Jenkins Cobertura Plugin

Usage

Put this in your mix.exs:

def project do
  [
    test_coverage: [tool: CoberturaCover]
  ]
end

defp deps do
  [
    {:cobertura_cover, "~> 0.9.0", only: :test}
  ]
end

Now you can run mix test --cover to generate a coverage.xml in your CI workflow.

If you only want to generate a coverage.xml in your CI workflow and generate HTML output on your workstation use this:

def project do
  [
    test_coverage: test_coverage(System.get_env("CI"))
  ]
end

defp test_coverage(nil), do: []
defp test_coverage(_), do: [tool: CoberturaCover]

defp deps do
  [
    {:cobertura_cover, "~> 0.9.0", only: :test}
  ]
end

If you want to get HTML output too you can configure it like this:

defp test_coverage(nil), do: []
defp test_coverage(_), do: [tool: CoberturaCover, html_output: "cover"]

cobertura_cover's People

Contributors

msch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cobertura_cover's Issues

No coverage detected

I made a very simple project with a few functions returning only a static value, like a number. I created doctests for some and regular ExUnit tests for others. Neither in the generated xml nor in the html files do any lines appear as covered.

No test coverage is recorded

When running mix test --cover with cobertura_cover enabled, the resulting XML file contains all relevant files/modules of my project, but all line_rate and branch_rate coverage metrics are reported as 0:

coverage xml 2016-02-19 09-53-00

However, when using the excoveralls package (Hex) there is test coverage:

COV    FILE                                        LINES RELEVANT   MISSED
  0.0% lib/guru/repo.ex                                3        0        0
  0.0% test/support/channel_case.ex                   41        3        3
100.0% test/support/conn_case.ex                      42        3        0
 75.0% test/support/model_case.ex                     61        4        1
  0.0% web/channels/user_socket.ex                    37        0        0
  0.0% web/controllers/auth_controller.ex             40       14       14
  0.0% web/controllers/image_controller.ex             7        1        1
100.0% web/controllers/page_controller.ex              7        1        0
  0.0% web/controllers/server_controller.ex            7        1        1
100.0% web/controllers/service_controller.ex          13        3        0
...
[TOTAL]  44.9%

Am I missing something, or does cobertura_cover not work with recent Elixir versions anymore? I noticed the latest release is from March 2015, which is almost a year ago...

โ‡’ elixir -v
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Elixir 1.2.2

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.