I want to understand what needs to be mocked and what not when writing test cases in general.
For example, we will mock I/O operations, but what about functions imported from another module. Are we supposed to mock them as well?
I want to understand what needs to be mocked and what not when writing test cases in general.
For example, we will mock I/O operations, but what about functions imported from another module. Are we supposed to mock them as well?
Mocking should be done for a reason. Good reasons are:
For example, you (typically) don't mock standard library math functions like sin
or cos
, because they don't have any of the abovementioned problems.
You really have to know what you are unit testing. From there it will be clear what to mock...