単体テストを実行するときに依存アプリケーションとしてラガーを起動しましたが、何らかの理由でテスト中のコードがそれを認識しません。
-module(main_tests).
-include_lib("eunit/include/eunit.hrl").
main_test_() ->
{foreach,
fun distr_setup/0,
fun distr_cleanup/1,
[
fun must_retain/1
]}.
must_retain(_) ->
{"Should do ping pong when is fully initialized",
fun() ->
?assertEqual(pong, abuse_counter:ping())
end}.
%%------------------------------------------------------------------
distr_setup() ->
abuse_counter:start_link(),
ok.
distr_cleanup(_) ->
abuse_counter:stop(),
ok.
これは、ラガーが定義されていないことを訴えているログの 出力です。
実行方法は次のとおりです。
erl -pa ebin/ ../../deps/*/ebin -s lager -eval 'eunit:test(main_tests,[verbose]), init:stop().'
出力で失敗する
Eshell V5.10.2 (abort with ^G)
1> 17:13:31.506 [info] Application lager started on node nonode@nohost
======================== EUnit ========================
module 'main_tests'
undefined
17:13:31.528 [error] CRASH REPORT Process <0.57.0> with 1 neighbours exited with reason: call to undefined function lager:info("up and running") in gen_server:init_it/6 line 328
*unexpected termination of test process*
::**{undef,[{lager,info,["up and running"],[]}**,
{abuse_counter,init,1,[{file,"src/abuse_counter.erl"},{line,37}]},
{gen_server,init_it,6,[{file,"gen_server.erl"},{line,304}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]}
=======================================================
Failed: 0. Skipped: 0. Passed: 0.
One or more tests were cancelled.
すでに Google とスタック オーバーフローに 3 ~ 4 時間費やしていますが、何も機能していないようです。
1 つのオプションは、この呼び出しを ?INFO(Mgs) マクロの背後に隠すことですが、この考えは気に入りません。
どんな助けでも大歓迎です。