| > What you call a stub is generally known as a Fake. I willingly accept your unconventional usage if it greases discussion, but the dictionary is right there. It records how most people use words. What mockery gives appears to be what most people consider a fake. It clearly does not fit the definition of mock. It arguably matches the definition of stub and I think you could reasonably call it that, but I posit that doesn't tell the whole story, which is no doubt why fake emerged. That said, I don't know what your definitions are. You seem to flail around with them. > Stubs do not react based on their input parameters. All of mocks, stubs, and fakes react based on input... > How would you test the case where the quota update fails with a stub? ... Although this seems like a poor example. It is not clear if the failure state is due to invalid input or due to some other issue. This, I must say, makes for a really bad test. Tests are, first and foremost, the contract and documentation for your users. They are written so that other people can learn about the system and know what they can depend on during use. The self-validation offered by testing is there merely to ensure that what is written in the contract is true. –– Not that we were expecting anything more from ChatGPT, but this does, interestingly, indicate yet another problem with mockery. I hadn't even picked up on that one earlier. Glad we were able to keep the discussion going to learn more! But, importantly, we lack necessary information to respond to your question. Perhaps you can clarify the intent here? |
My suggestion is for you to provide code how you would test the same handler code and scenario using your methodology.
Show me a test that checks the error handling of quota check. Pretend the quota service is experiencing an outage on the second request you make to it.