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

Tim Watson watson.timothy@REDACTED
Sun Jul 3 22:17:03 CEST 2011


On 3 July 2011 20:24, Rudolph van Graan <rvg.mailing@REDACTED> wrote:
> Hi there,
>
> 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.
>

You could use a hamcrest matcher from within the eunit test case. That
would at return a formatted (an not truncated) representation. You can
also set up a "heckle" function to notify what is being checked and
against which expectations.

The library is quite early stages, but I'll happily fix issues and/or
take pull requests to make it more useful.

t4@REDACTED:~ $ erl
Erlang R14B01 (erts-5.8.2) [source] [64-bit] [smp:2:2] [rq:2]
[async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.8.2  (abort with ^G)
1> X = [{specification_error,duplicate_element,"Duplicate",
1>                       [{element_spec,12,[{foo,bar},baz]},
1>                        {element_spec,14,[{a,b},{c,d}]}]}]
2> Result = hamcrest:check([X,X,X,X], hamcrest_matchers:equal_to(abc)).
{assertion_failed,"Expected a value equal to [abc], but was
[[[{specification_error,\n
duplicate_element,\"Duplicate\",\n
        [{element_spec,12,\n
    [{foo,bar},baz]},\n
{element_spec,14,\n
[{a,b},{c,d}]}]}],\n
[{specification_error,\n
duplicate_element,\"Duplicate\",\n
        [{element_spec,12,\n
    [{foo,bar},baz]},\n
{element_spec,14,\n
[{a,b},{c,d}]}]}],\n
[{specification_error,\n
duplicate_element,\"Duplicate\",\n
        [{element_spec,12,\n
    [{foo,bar},baz]},\n
{element_spec,14,\n
[{a,b},{c,d}]}]}],\n
[{specification_error,\n
duplicate_element,\"Duplicate\",\n
        [{element_spec,12,\n
    [{foo,bar},baz]},\n
{element_spec,14,\n
[{a,b},{c,d}]}]}]]]"}
3>



More information about the erlang-questions mailing list