[erlang-questions] Getting eunit to display the full term?

Klas Johansson klas.johansson@REDACTED
Mon Jul 4 13:06:43 CEST 2011


Hi,

On Mon, Jul 4, 2011 at 11:15 AM, Richard Carlsson
<carlsson.richard@REDACTED> wrote:
> On 07/04/2011 07:01 AM, Garrett Smith wrote:
>>
>> On Sun, Jul 3, 2011 at 1:24 PM, Rudolph van Graan<rvg.mailing@REDACTED>
>>  wrote:
>>>
>>> Is there a simple way (other than changing the source) to make eUnit
>>> display
>>> the entire term that didn't match in its output instead of the ...
>>> truncation? I find it pointless to have write a manual version of the
>>> test
>>> just to see what is not matching.
>>
>> It's not elegant, but I insert io:format("~p", [Result]) in places
>> where the result gets truncated.
>>
>> Output via io:format is suppressed when the test succeeds, suggesting
>> that this is somehow a feature.
>>
>> I would argue though that this is a design flaw in eunit -- results
>> should not be truncated.
>
> EUnit doesn't truncate the results at the source, but only in the tty
> output. There should probably be an option to the tty output module to
> control the truncation depth, but in general, you really want the tty output
> to be fairly short, or in many cases you'll just drown in thousands of lines
> of output per failed test.
>
> What's currently missing is a file logger backend, to write the complete (or
> as deep as you want) output to a file. It shouldn't be hard to make, if
> anyone has the time: copy the module eunit_tty and adapt it a bit, then hook
> it in as a standard option in the main eunit module. While developing, you
> can hook in your module using the option {report, X} where X = {Mod, Opts}
> for a listener module Mod called as Mod:start(Opts), or X = Pid/Atom for an
> existing listener process. See also the docs for eunit_surefire, which is a
> similar but slightly more complicated plugin.
>
> And of course, if anyone has ideas for other kinds of listeners, go ahead -
> it's not hard to make one. Sorry that I haven't had time to document the
> callback interface yet, but it's considered stable now. See the
> eunit_surefire docs as an example.

To people who start looking at eunit_surefire: you might want to have
a look at the version which is cooking on the `pu' branch, since the
one in `dev' is slightly broken when it comes to handling groups of
tests.

https://github.com/erlang/otp/tree/pu/lib/eunit/src


Cheers,
Klas



More information about the erlang-questions mailing list