There are probably lots of similar questions here but I still don't understand how it's done.
Let's say I have the following trivial module:
defmodule ModuleOne do
def do_something(argument) do
argument
|> do_first_thing()
|> do_second_thing()
|> ModuleTwo.do_something()
end
end
Now, I have ModuleTwo
covered with tests so it doesn't make sense to duplicate that testing logic. Also it's not Twitter API
module or something of the kind so I dont think it's a good idea to come up with a compile-time mock module ( as far as I can see, it's a good idea in case cases, like HTTP calls but doing that for every external module call will obviously turn into a mess ) and also I don't want to pass a function as an argument just for the sake of testing ( especially if I have calls to multiple external modules ) because it messes up the interface with unnecessary things.
Also people suggest not to use mocks, like the meck
library, which is the most obvious decision here, but I don't understand why ...
Anyway, what would be a good way to test this module considering all the suggestions above?
Thank you
Aucun commentaire:
Enregistrer un commentaire