[erlang-questions] rebar3 and Coverage log

Fred Hebert mononcqc@REDACTED
Sat Nov 17 22:40:06 CET 2018

On 11/17, Caragea Silviu wrote:
>When running rebar ct with {cover_enabled, true}. Inside the "Coverage log"
>page I can see the coverage results with a nice look.
>After migrating to rebar3 I see that beside cover_enabled I need to add as
>well {cover_export_enabled, true}, but the results are in a separate folder
>cover\index.html and this one looks very crappy.
>"Coverage log" form the page where tests are listed shows "Cover tool is
>not used " ..
> ...
>I'm missing something or "Coverage log" is not longer working with rebar3 ?

In rebar3, the default coverage tool used is the `cover` library itself.  
Rather than tunneling the feature through Common Test (as rebar did it, 
and how CT handles it), rebar3 stores a bunch of intermediary log covers 
for each tool. By default, eunit and CT are covered that way, but 
external providers such as https://github.com/ferd/rebar3_proper can 
also use the same tool.

The final result is that you can now aggregate the coverage from all 
tools at once: `rebar3 do eunit -c, ct -c, proper -c, cover` will give 
you the coverage of your code from all tools bundled together. If you 
call `cover` as a task explicitly, you won't need to add 
`cover_export_enabled` as an option. One thing most of my projects have 
is an alias task such as:

    {alias, [
        {check, [xref, dialyzer, edoc,
                 {proper, "--regressions"},
                 {proper, "-c"}, {ct, "-c"},
                 {cover, "-v --min_coverage=80"}

(taken from https://github.com/ferd/flatlog)

This runs xref, dialyzer, checks that the doc can build, runs all test 
frameworks, and outputs coverage. By isolating the cover reporting into 
its own task, we also were able to add further checks like 
`--min_coverage=$PERCENTAGE` which fails the build if too little test 
coverage is given.

The reporting is now uglier (because that's what the cover library 
exports), but it is more composable when using multiple test frameworks, 
and we're able to add interesting checks. The whole sequence is callable 
as `rebar3 check` and off you go.

Hopefully this kind of stuff helps cope with the uglier coverage 
analysis reports :)


More information about the erlang-questions mailing list