Skip to content

Commit

Permalink
Fix parameterized fixtures to tear down after each test case
Browse files Browse the repository at this point in the history
  • Loading branch information
MattVonVielen committed Jun 30, 2015
1 parent 6c3fab0 commit 166e711
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/hoax.app.src
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{application, hoax,
[
{description, "Yet another mocking library for Erlang"},
{vsn, "0.10.1"}
{vsn, "0.10.2"}
]}.
2 changes: 1 addition & 1 deletion src/hoax.erl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fixture_tuple(Module, Arity, UserSetup, UserTeardown, Selector) when is_function
Tests = [fun Module:F/Arity || {F, A} <- Module:module_info(exports), A == Arity, Selector(F) == true],
TestList = case Arity of
0 -> Tests;
1 -> [{with, Tests}]
1 -> [{with, [T]} || T <- Tests]
end,
{foreach,
fun() -> start(), UserSetup() end,
Expand Down
12 changes: 6 additions & 6 deletions test/hoax_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,31 @@ parameterized_fixture_for_entire_module_with_setup_and_teardown_calls_setup_and_
?assertEqual({true, some_argument}, erlang:get(teardown_called)).

parameterized_fixture_for_entire_module_with_setup_and_teardown_omits_setup_and_teardown_test() ->
ExpectedSortedFunctions = [ fun ?EXAMPLE_MODULE:F/1 || F <- [
ExpectedSortedFunctions = [ {with, [fun ?EXAMPLE_MODULE:F/1]} || F <- [
parameterized_test_function1, parameterized_test_function2,
prefix1_parameterized_test_function_1, prefix1_parameterized_test_function_2, prefix1_teardown,
prefix2_parameterized_test_function_1, prefix2_parameterized_test_function_2, prefix2_teardown
]],

{foreach, _, _, [{with, Tests}]} = hoax:parameterized_fixture(?EXAMPLE_MODULE, setup, teardown),
{foreach, _, _, Tests} = hoax:parameterized_fixture(?EXAMPLE_MODULE, setup, teardown),

?assertEqual(ExpectedSortedFunctions, lists:sort(Tests)).

parameterized_fixture_with_atom_prefix_with_setup_and_teardown_selects_functions_by_prefix_omitting_setup_and_teardown_test() ->
ExpectedSortedFunctions = [ fun ?EXAMPLE_MODULE:F/1 || F <- [
ExpectedSortedFunctions = [ {with, [fun ?EXAMPLE_MODULE:F/1]} || F <- [
prefix1_parameterized_test_function_1, prefix1_parameterized_test_function_2
]],

{foreach, _, _, [{with, Tests}]} = hoax:parameterized_fixture(?EXAMPLE_MODULE, prefix1, prefix1_setup, prefix1_teardown),
{foreach, _, _, Tests} = hoax:parameterized_fixture(?EXAMPLE_MODULE, prefix1, prefix1_setup, prefix1_teardown),

?assertEqual(ExpectedSortedFunctions, lists:sort(Tests)).

parameterized_fixture_with_string_prefix_with_setup_and_teardown_selects_functions_by_prefix_omitting_setup_and_teardown_test() ->
ExpectedSortedFunctions = [ fun ?EXAMPLE_MODULE:F/1 || F <- [
ExpectedSortedFunctions = [ {with, [fun ?EXAMPLE_MODULE:F/1]} || F <- [
prefix2_parameterized_test_function_1, prefix2_parameterized_test_function_2
]],

{foreach, _, _, [{with, Tests}]} = hoax:parameterized_fixture(?EXAMPLE_MODULE, "prefix2", prefix2_setup, prefix2_teardown),
{foreach, _, _, Tests} = hoax:parameterized_fixture(?EXAMPLE_MODULE, "prefix2", prefix2_setup, prefix2_teardown),

?assertEqual(ExpectedSortedFunctions, lists:sort(Tests)).

Expand Down

0 comments on commit 166e711

Please sign in to comment.