| > You could pass anything into the dependency parameters and the test would pass. I don't follow. Under no circumstance would the test pass under invalid inputs, be it whether you use mocks, stubs, or even mockery (fakes?). - Obviously it cannot pass while using mocks – a mock matches the real thing to every last detail. If it will fail while using the real thing, it will fail here as well. - Obviously it cannot pass while using stubs – a stub matches the real thing, partially, to at least the minimum amount necessary for the sake of testing. If it will fail while using the real thing, it will fail here as well. - Obviously it cannot pass while using mockery – mockery does not match the real thing in any way, but does require you to specify matching inputs with failure when they don't match. If it will fail while using the real thing, it will fail here as well. I don't know what you are imagining, but I'm not convinced it is a thing. I mean, you could make it a thing - you can do anything your little heart desires, but there would be no reason to ever make it a thing. Maybe we need some concrete tests to better illustrate what you are talking about? |
https://stackoverflow.com/questions/3459287/whats-the-differ...
Stubs do not react based on their input parameters. However, even fakes have the issue of fault injection.
I don't want to just test valid inputs. I want to make sure I pass the correct inputs for the request parameters through to the dependencies. If pass 100.00 in the request but in my impl I pass 0.00 to the stub. The test will pass because the input is valid. But the implementation is not correct.
Also, mockery is just an alternative mocking api. There is nothing special here.
How would you test the case where the quota update fails with a stub? Here is mockery example again generated with chatgpt.