I generally try to avoid mocking completely. However, speeding up tests is an appropriate use. If someone changes the implementation the mock usually simply doesn't apply and the test still works as intended.
For example, a great speed optimization in our tests recently was to mock time.sleep.
Why do we have so many sleeps? This is testing a test framework for embedded devices where there is plenty of fiddling-then-wait-for-the-hardware.
I also mocked some file system accesses. Unit testing is about our application logic and not about Linux kernel behavior anyways.
For example, a great speed optimization in our tests recently was to mock time.sleep.
Why do we have so many sleeps? This is testing a test framework for embedded devices where there is plenty of fiddling-then-wait-for-the-hardware.
I also mocked some file system accesses. Unit testing is about our application logic and not about Linux kernel behavior anyways.