EUnit basic issues with generator

271 views Asked by At

I am doing a basic test with EUnit :

setup() ->
  [1, 2].
teardown(_) ->
  ended.
success([H, T]) ->
  ?_assert(H =:= 1),
  ?_assert(H =:= 2),
  foo.
setup_test_() ->
  {setup,
    fun setup/0,
    fun teardown/1,
    fun success/1}.

And I don't get basically every line of the output (except the result failed / passed):

2> erl_start:test().
undefined
*** test module not found ***
**foo

=======================================================
  Failed: 0.  Skipped: 0.  Passed: 4. 
One or more tests were cancelled.
error
3>

Can someone explain what is the meaning of each line ?

1

There are 1 answers

0
Simon On

This answers pretty well the question.

Generators should only return a test function or a list of tests functions (?_xxx).

In my example, the good success fun is :

success([H, T]) ->
  [?_assert(H =:= 1),
   ?_assert(T =:= 2)].