You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2017/09/28 21:02:29 UTC

[21/50] meck commit: updated refs/heads/master to 3544aca

Detail edge cases of validate/1


Project: http://git-wip-us.apache.org/repos/asf/couchdb-meck/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-meck/commit/10c50634
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-meck/tree/10c50634
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-meck/diff/10c50634

Branch: refs/heads/master
Commit: 10c50634b57d1f7ce5205e2fae56e700c4da3397
Parents: f0904dc
Author: Adam Lindberg <he...@alind.io>
Authored: Fri Apr 7 16:31:48 2017 +0200
Committer: Adam Lindberg <he...@alind.io>
Committed: Fri Apr 7 16:31:48 2017 +0200

----------------------------------------------------------------------
 src/meck.erl | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-meck/blob/10c50634/src/meck.erl
----------------------------------------------------------------------
diff --git a/src/meck.erl b/src/meck.erl
index 0ed87ec..adb09e8 100644
--- a/src/meck.erl
+++ b/src/meck.erl
@@ -349,6 +349,31 @@ passthrough(Args) when is_list(Args) ->
 %% arguments or non-existing function (undef), wrong arguments
 %% (function clause) or unexpected exceptions.
 %%
+%% Validation can detect:
+%%
+%% <ul>
+%%   <li>When a function was called with the wrong argument types
+%%       (`function_clause')</li>
+%%   <li>When an exception was thrown</li>
+%%   <li>When an exception was thrown and expected (via meck:exception/2),
+%%       which still results in `true' being returned</li>
+%% </ul>
+%%
+%% Validation cannot detect:
+%%
+%% <ul>
+%%   <li>When you didn't call a function</li>
+%%   <li>When you called a function with the wrong number of arguments
+%%       (`undef')</li>
+%%   <li>When you called an undefined function (`undef')</li>
+%% </ul>
+%%
+%% The reason Meck cannot detect these cases is because of how it is implemented.
+%% Meck replaces the module with a mock and a process that maintains the mock.
+%% Everything Meck get goes through that mock module. Meck does not insert
+%% itself at the caller level (i.e. in your module or in your test case), so it
+%% cannot know that you failed to call a module.
+%%
 %% Use the {@link history/1} or {@link history/2} function to analyze errors.
 -spec validate(Mods) -> boolean() when
       Mods :: Mod | [Mod],