3 ms·
Interesting. However, I find mocks useful when I try to replicate error handling in case of unexpected exceptions. How do I replicate that with a Fake? A flag
by leidenfrost 4y ago
Interesting. However, I find mocks useful when I try to replicate error handling in case of unexpected exceptions.
How do I replicate that with a Fake? A flag for error triggering?
- sethammons 4y agoIn Go, I create a struct with two properties: err and value. When err is set, it returns that, else returns the value. In the test, I create the fake and set its err to whatever and then verify handling. As needed, you can add properties and add a delay to the response if set.