Closed elpaisa closed 7 years ago
This is how my tests look like:
setup() ->
al_soc_elk_service:set_env(workers, get_test_workers()),
meck:expect(incidents, documents, fun(WorkerName, Cid, StartTime, EndTime) ->
[WorkerName, Cid, StartTime, EndTime, []] end),
meck:expect(al_soc_elk_service_stats, set_status, fun(_WorkerName, _Key, _Value) ->
ok end),
meck:expect(al_soc_elk_service_customers, get_customers, fun() ->
[{1, <<"Test Customer 1">>}, {2, <<"Test Customer 2">>}] end),
meck:expect(al_soc_elk_service_elasticsearch, prepare, fun(_Date, _Type) ->
ok end),
meck:expect(al_soc_elk_service_elasticsearch, start, fun() ->
ok end),
meck:expect(gascheduler, start_link, fun(_Scheduler, _Nodes, _Client, _MaxWorkers, _MaxRetries) ->
{ok, c:pid(0,250,0)} end),
meck:expect(al_soc_elk_service_db, start, fun(_DB) ->
{ok, c:pid(0,251,0)} end),
meck:expect(gascheduler, execute, fun(_, _) ->
ok end),
{[incidents, gascheduler, al_soc_elk_service_stats, al_soc_elk_service_customers,
al_soc_elk_service_elasticsearch, al_soc_elk_service_db]}.
teardown({Apps}) ->
meck:unload(Apps),
ok.
all_test_() ->
{
setup,
fun setup/0,
fun teardown/1,
[
{"scheduler", {timeout, ?TEST_TIMEOUT, fun test_scheduler/0}},
{"workers", {timeout, ?TEST_TIMEOUT, fun test_workers/0}},
{"stop_all", {timeout, ?TEST_TIMEOUT, fun test_stop_all/0}},
{"cache", {timeout, ?TEST_TIMEOUT, fun test_cache/0}},
{"set_workers", {timeout, ?TEST_TIMEOUT, fun test_set_workers/0}},
{"others", {timeout, ?TEST_TIMEOUT, fun test_others/0}}
]
}.
rebar.config
%%-*- mode: erlang -*-
%% ex: ft=erlang
%% {require_otp_vsn, "R19"}.
{erl_opts, [debug_info]}.
{version, "1.0.0"}.
%%{run_user, "root"}.
{sub_dirs, ["rel"]}.
{deps, [
%% third party
{jsonx, "", {git, "https://github.com/elpaisa/jsonx.git", {branch, master}}},
%% Add meck to the list of dependencies
{meck, "", {git, "https://github.com/basho/meck.git", {tag, "0.8.4"}}},
%% Include covertool as a dependency
{mysql, "", {git, "https://github.com/mysql-otp/mysql-otp.git", {tag, "1.2.0"}}},
{gascheduler, "", {git, "https://github.com/GameAnalytics/gascheduler", {tag, "1.1.0"} }},
{elasticsearch, "", {git, "https://github.com/elpaisa/erlangelk", {tag, "0.0.5"}}},
{qdate, "", {git, "https://github.com/elpaisa/qdate", {tag, "0.4.3"}}},
{egeoip, "", {git, "https://github.com/mochi/egeoip", {branch, master}}},
lhttpc
]}.
{plugins, [rebar_covertool]}.
{pre_hooks, [{clean, "rm -rf ebin test/*.beam dialyzer.output .eunit erl_crash.dump logs/* *.log *.coverage.xml"}]}.
{post_hooks, [{'delete-deps', "rm -rf deps .dialyzer_deps_plt"}]}.
{ct_extra_params, "-ct_hooks cth_surefire -erl_args -config erl.config"}.
{cover_enabled, false}.
{cover_export_enabled, false}.
{cover_print_enabled, false}.
{covertool_eunit, {".eunit/cover.coverdata", "eunit.coverage.xml"}}.
{covertool_ct, {"ct.coverdata", "ct.coverage.xml"}}.
{covertool_prefix_len, 2}. % Optional: Use module prefix as (imaginary) package name
{shell, [
{apps, [al_soc_elk_service]},
{config, "config/sys.config"}
]}.
{relx, [
{release, {al_soc_elk_service, "0.0.1"},
[al_soc_elk_service]
},
{dev_mode, false},
{include_erts, false},
{extended_start_script, true},
{sys_config, "config/sys.config"},
{vm_args, "config/vm.args"}
]}.
{deps_dir, "lib"}.
are you using precompiled beam files (or using a tool that generates them?) cover can't work on files that don't include debug info. this error message could definitely be more helpful though
I was having the problem with Macports Erlang 19.2, i installed Homebrew Erlang 19.3 and the issue is gone.
I'm having an issue running rebar3 coverage,
Command is: rebar3 eunit --cover
It does all the unit tests and they run ok, but when it comes to coverage it errors with:
Rebar report results: