Display full expected and value information when? _assertEqual does not work

I am encoding a unit test where a (rather long) binary is generated, and I want to maintain that the generated binary is equal to the one I expect to be generated. I run eunit through the reinforcement eunit .

The thing is, when this statement fails, it prints with " ... ", and I want to see the full output so that I can determine where the difference is.

Now I use " ? DebugFmt () " as a temporary solution, but I would like to know if there is an alternative there (an option or configuration argument somewhere that can be applied to " ? _ AssertEqual () ", so the output is only shown when unsuccessful statement).

Thanks in advance!

EDIT: due to legoscia's answer , I am including a test sample using a test generator with a few statements:

can_do_something(SetupData) ->
    % ... some code ... 
    [?_assertEqual(Expected1, Actual1), ?_assertEqual(Expected2, Actual2)].
+5
source share
3 answers

The best I can imagine for actually displaying the value in the console is something like this:

Actual =:= Expected orelse ?assert(?debugFmt("~p is not ~p", [Actual, Expected]))

?debugFmtreturns ok, which is false, so the statement always fails.

, , ?_assert:

?_assert(Actual =:= Expected orelse ?debugFmt("~p is not ~p", [Actual, Expected]))
+4

, XML Eunit ( Surefire, AKA "Junit" ). XML , , , , .

rebar.config:

{eunit_opts, 
 [verbose,
  %% eunit truncates output from tests - capture full output in
  %% XML files in .eunit
  {report,{eunit_surefire,[{dir,"."}]}}]}.

foo .eunit/TEST-foo.xml. .

+3

1). Open eunit sources. In my system:

cd /usr/lib/erlang/lib/eunit-2.3.2/src

2). Modify eunit_lib.erl as follows:

diff

54c54
<     format_exception(Exception, 20).
---
>     format_exception(Exception, 99999).

3). sudo erlc -I ../include eunit_lib.erl

4). mv eunit_lib.beam ../ebin

5). Have a nice day))

+3
source

All Articles