0

I am not an expert in EUnit and I mainly use ?assert_(fun1(Args) == Result) to test all the functions in my Erlang code (I define Result in the _tests module).

But in case a test fails it does not show what fun1 has actually returned.

Instead, it says something like "It should be true, but was false".

How can I make EUnit to show in its output what fun1(Args) has actually returned?

skanatek
  • 5,133
  • 3
  • 47
  • 75

1 Answers1

3

You can use the ?assertEqual(Expect, Expr) macro:

?assertEqual(Result, fun1(Args))

For more ?assert macros, check eunit docs

Isac
  • 2,058
  • 16
  • 23
  • 2
    Also, check out this hidden treasure of eunit examples: [github.com/richcarl/eunit/](https://github.com/richcarl/eunit/blob/master/examples/eunit_examples.erl) I often use it as a reference when writing eunit tests. – selle Feb 17 '12 at 20:22