[erlang-questions] Structuring an Eunit Suite

Adam Lindberg <>
Thu Jan 15 13:12:59 CET 2009


So maybe:

connection_test_() ->
    Connections = [new_connection, some_other_connection],
    Tests = [foo_test, bar_test, baz_test],
    [make_test(C, T) || C <- Connections, T <- Tests].
    
make_test(Connection, Test) ->
    test_util:Test(Connection()).


This would give the permutation:

1> [make_test(C, T) || C <- Connections, T <- Tests].
[{new_connection,foo_test},
 {new_connection,bar_test},
 {new_connection,baz_test},
 {some_other_connection,foo_test},
 {some_other_connection,bar_test},
 {some_other_connection,baz_test}]

Cheers,
Adam

----- "Ben Hood" <> wrote:

> Adam,
> 
> On Thu, Jan 15, 2009 at 11:23 AM, Adam Lindberg
> <> wrote:
> > foo_test_() ->
> >    lists:map(fun test_util:foo_test/1, [new_connection(),
> some_other_connection()]).
> >
> > Does this seem to be what you want?
> 
> No, it's the other way around.
> 
> The test_util module has n exported test functions, so I'd like to be
> able to run every function and pass in the specific connection every
> time, e.g.
> 
> test_util:foo_test(new_connection()),
> test_util:bar_test(new_connection()),
> test_util:baz_test(new_connection()),
> 
> ...... and so on for each test in the test_util module.
> 
> Ben



More information about the erlang-questions mailing list