Skip to content

Commit

Permalink
Added an ok in the end of the tests that use a helper function with a…
Browse files Browse the repository at this point in the history
…sserts.

A failing test, run by foreach, does not show up in the stack trace if
it fails in it's last statement and that statement is a call to
another function where the asserts are.  This is typically the case
for all the called_ tests.  This can be helped by putting an ok in
the end.
  • Loading branch information
daha committed Oct 12, 2011
1 parent 5dd556e commit d995e04
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions test/meck_tests.erl
Expand Up @@ -333,54 +333,63 @@ delete_(Mod) ->
called_false_no_args_(Mod) ->
Args = [],
ok = meck:expect(Mod, test, length(Args), ok),
assert_called(Mod, test, Args, false).
assert_called(Mod, test, Args, false),
ok.

called_true_no_args_(Mod) ->
Args = [],
ok = meck:expect(Mod, test, length(Args), ok),
ok = apply(Mod, test, Args),
assert_called(Mod, test, Args, true).
assert_called(Mod, test, Args, true),
ok.

called_true_two_functions_(Mod) ->
Args = [],
ok = meck:expect(Mod, test1, length(Args), ok),
ok = meck:expect(Mod, test2, length(Args), ok),
ok = apply(Mod, test1, Args),
ok = apply(Mod, test2, Args),
assert_called(Mod, test2, Args, true).
assert_called(Mod, test2, Args, true),
ok.

called_false_one_arg_(Mod) ->
Args = ["hello"],
ok = meck:expect(Mod, test, length(Args), ok),
assert_called(Mod, test, Args, false).
assert_called(Mod, test, Args, false),
ok.

called_true_one_arg_(Mod) ->
Args = ["hello"],
ok = meck:expect(Mod, test, length(Args), ok),
ok = apply(Mod, test, Args),
assert_called(Mod, test, Args, true).
assert_called(Mod, test, Args, true),
ok.

called_false_few_args_(Mod) ->
Args = [one, 2, {three, 3}, "four"],
ok = meck:expect(Mod, test, length(Args), ok),
assert_called(Mod, test, Args, false).
assert_called(Mod, test, Args, false),
ok.

called_true_few_args_(Mod) ->
Args = [one, 2, {three, 3}, "four"],
ok = meck:expect(Mod, test, length(Args), ok),
ok = apply(Mod, test, Args),
assert_called(Mod, test, Args, true).
assert_called(Mod, test, Args, true),
ok.

called_false_error_(Mod) ->
Args = [one, "two", {3, 3}],
TestFun = fun (_, _, _) -> meck:exception(error, my_error) end,
ok = meck:expect(Mod, test, TestFun),
assert_called(Mod, test, Args, false).
assert_called(Mod, test, Args, false),
ok.

called_true_error_(Mod) ->
Args = [one, "two", {3, 3}],
expect_catch_apply(Mod, test, Args),
assert_called(Mod, test, Args, true).
assert_called(Mod, test, Args, true),
ok.

called_with_pid_no_args_(Mod) ->
Args = [],
Expand Down Expand Up @@ -441,7 +450,8 @@ called_wildcard_(Mod) ->
Args = [one, 2, {three, 3}, "four"],
ok = meck:expect(Mod, test, length(Args), ok),
ok = apply(Mod, test, Args),
assert_called(Mod, test, [one, '_', {three, '_'}, "four"], true).
assert_called(Mod, test, [one, '_', {three, '_'}, "four"], true),
ok.

sequence_(Mod) ->
Sequence = [a, b, c, d, e],
Expand Down

0 comments on commit d995e04

Please sign in to comment.