MakeAWishFoundation / SwiftyMocky

Framework for automatic mock generation. Adds a set of handy methods, simplifying testing. One of the best and most complete solutions, including generics support and much more.
MIT License
1.03k stars 104 forks source link

There is no fallback data, if no 'Given` method provided. #349

Open AhmedMohamedAllam opened 1 year ago

AhmedMohamedAllam commented 1 year ago

I have a NetworkProtocol, that have request() method there are some test cases, where the flow can call the network, but I dinidn't provide a Given call in this test. is there a way to fallback to a default value if no mocks found? and also it doesn't point to where the mocked data are missing it fails only without any further information.

Stannieman commented 5 months ago

Disclaimer: I'm not a maintainer of this project. But IMO having default return values is a bad idea. The only scenario where the default is used is if the tested code interacts with the mocks in a way the test did not foresee. In that case, how much value is the test adding? If the test did not foresee that a mock is used in a certain way, how can that same test still prove that the tested code works correctly? The (default) return value is usually used for something, something which is probably not covered by the test if a default would be ok for you.