[erlang-questions] Why use test generators?

ryeguy <>
Fri Mar 27 04:45:09 CET 2009


As the title says, what situation would you be in when you would use
test generators? The example the docs give is this:

   fib_test_() ->
       [?_assert(fib(0) == 1),
        ?_assert(fib(1) == 1),
        ?_assert(fib(2) == 2),
        ?_assert(fib(3) == 3),
        ?_assert(fib(4) == 5),
        ?_assert(fib(5) == 8),
        ?_assertException(error, function_clause, fib(-1)),
        ?_assert(fib(31) == 2178309)
       ].

Why would you use a list of tests instead of just singlely evaluating
each one on its own linein the fib_test() method?



More information about the erlang-questions mailing list