I don’t want this to come across as rebuttal to Jose Valim’s assertion on not mocking as a verb, I’m just struggling with it.
The problem I have is coverage.
All the examples I’ve seen, using a Mock agent with meeting an @behavior contract basically are one-test scenarios, covering one use case. Once the behavior of the mock is written, in order to change the output of the Mock, it would seem that the proposal is to create a Mock object for each test case, that just seems… kind of batshit.
For instance if I have a Mock http client, and I want to test how code responds to the 200 response code, 400 response code, and 500 response code. My mock http client would have one .get() method and it would always return whatever I define as the return result, what exactly is the proposal to test a .get() consumer to validate that the consumer responds to the various conditions correctly?
I’m new to Elixir, coming from C#, NodeJs and Golang… So all of my testing experience has used mocks, and being told by the language creator it’s wrong is just really tough for me to get my head around how to inject fixed values so that the unit under test behaves how I want it to under specific circumstances. Being new to functional programming is the source of my confusion, but some good examples where Jose’s mocking technique that covers multiple behaviors for a single function would help me.