-
-
Notifications
You must be signed in to change notification settings - Fork 230
Description
Hi,
Consider the following example. We want some mocked function to return different values in different cases. Normally, this is being done either using something like meck:seq/1
or by calling meck:expect/4
in-place.
The sequencing approach can be a problem if there's no determined mount of calls to be made. For example, when we have some periodic calls, or when we have a complex call tree that calls our mocked function not once or twice. We may not even care about the amount of function calls made, just the fact that its return value was always the defined one.
Calling meck:expect/4
in place is much better from the semantics perspective but it's painfully slow, as we recompile the module every time. As a result, simple tests may start taking 5-10 seconds instead of sub-seconds.
Is it technically possible to use something like ETS tables for storing meck:expect
table, or there were some technical limitations that made you require to recompile the module? I ended up having that ETS-based approach for some cases and now wonder if meck:expect/4
could be changed to work this way, which is much faster, or another function like meck:quick_expect/4
can be added as a wrapper, because this seems like a fairly common pattern.
Thanks!