Tests that rely on private methods

Different sort of tests. Yes, the API tests are the most important. They are there to make sure you don’t break the contract of your public API, but I think it is a very bad idea to test implementation detail here. Your users don’t care about implementation detail and I don’t think these tests should either. But the implementation has to be tested somewhere.

Perhaps it is more idomatic in elixir to lift this out into a “private” module as @josevalim suggests but for me this is the same concept as having privates tests. Just a different implementation.[quote=“sasajuric, post:16, topic:9281”]
Finally, it’s worth noting that in Elixir, functions which are public but not meant to be invoked directly, should be marked with @doc false. This should indicate that a function is internal (even though marked public), and the clients should not depend on it directly. Such function will not appear in the generated doc, and the users will be unaware of its existence. People who read the code will see the function, but they will also see that it is marked with @doc false, and hence not meant to be invoked directly.
[/quote]

Thanks, I wasn’t aware of this option

1 Like

this was informative, thank you very much :smile: