Let us say I have a module called example.erl
In this module I use the following construct for debugging:
%%% Switch debugging output on/off:
%-define(DBG(Str, Args), ok).
-define(DBG(Str, Args), io:format(Str, Args)).
It helps me to output various debugging info into the Erlang shell:
?DBG("Function fun1 starting... ~n", [])
But if I call example.erl
from example_tests
with example:test()
, this output info does not appear.
How can I make it visible during a EUnit test?
UPD: I have found some related info, but I still do not know how to solve the issue.
As describe in the page you mention, you can use debugMsg or debugFmt.
?debugMsg("Function fun1 starting...")
or
?debugFmt("Function fun1 starting...", [])
Make sure you have include eunit's header file in your module file.
-include_lib("eunit/include/eunit.hrl").
If you want to disable debug macros for example in staging, define NODEBUG in compiling modules.