rebar3 and Coverage log

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

rebar3 and Coverage log

Caragea Silviu
Hello,

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 " ..

My rebar.config has:

{cover_enabled, true}.
{cover_export_enabled, true}.

{relx, [
    {release, {myapp, "1.0" }, [myapp]},
    {sys_config, "sys.config"},
    {vm_args,    "vm.args"},
    {dev_mode, true},
    {include_erts, false},
    {extended_start_script, true}
]}.

{profiles, [
    {release, [
        {relx, [
            {sys_config, "sys.config"},
            {vm_args,    "vm.args"},
            {dev_mode, false},
            {include_erts, true}
        ]}
    ]},
    {test, [
        {erl_opts, [debug_info, {d, 'common_test'}]},
        {ct_opts, [
            {spec, "test/cover.spec"},
            {sys_config, ["sys.config"]}
        ]}
    ]}
]}.

And inside test\cover.spec I have:

{level, details}.
{incl_dirs, [
   "_build/test/lib/myapp/ebin"
]}.

{excl_mods, [
    profiling,
    test
]}.

I'm missing something or "Coverage log" is not longer working with rebar3 ?

Silviu

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: rebar3 and Coverage log

Fred Hebert-2
On 11/17, Caragea Silviu wrote:

>Hello,
>
>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 ?
>
>Silviu

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 :)

Regards,
Fred.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions