2013-10-31 2 views
0

단위 테스트를 실행할 때 lager를 종속 응용 프로그램으로 시작하지만 어떤 이유로 테스트 대상 코드가 표시되지 않습니다. 여기 종속 응용 프로그램을 eunit과 함께 시작하십시오.

-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 [email protected] 
======================== 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. 

이미 지출 3-4h 시간을 실패하고 스택 오버 플로우하지만 아무것도 작동하는 것 같다 : 여기

내가 그것을 실행하는 방법입니다.

하나의 옵션은? INFO (Mgs) 매크로 뒤에이 호출을 숨기지 만 아이디어가 마음에 들지 않습니다.

도움이 될 것입니다.

답변

4

src/abuse_counter.erl 파일이 {parse_transform, lager_transform} 옵션으로 컴파일되지 않은 것처럼 보입니다.

함수 lager:info("message!")이 실제로 존재하지 않으므로 parse_transform은 lager:info("message!")lager:dispatch_log(info, Metadata, "message!", [], Size)으로 변환합니다.

{parse_transform, lager_transform} 옵션을 사용하여 모듈을 다시 컴파일 해보십시오.

등급 표시 방법 : link to the Readme.