Re:Testing Without Mocks: A Pattern Language
by u801e on Sunday January 08, 2023 @02:03AM
(#34296795)
> I've seen code with so much mocked that many unit tests failed to test anything other than behaviour of mocks.
One example of this was a test that passed because of the expected behavior as determined by a mock, but the code failed in the staging environment because the underlying library changed its method signature to take some parameters in a different order.
To me, this basically was a signal that that particular test and tests like it were essentially useless in determining whether the code was really in a working state.
Re:Testing Without Mocks: A Pattern Language
by flippinburgers on Sunday January 08, 2023 @04:57AM
(#34297665)
This is the major achilles heal of mocking that I find to be most bothersome. If at all possible I try to have at least a happy path subset of real tests hitting real 3rd party apis if I possibly can.
I've seen code with so much mocked that many unit tests failed to test anything other than behaviour of mocks.
Not sure I'm comfortable with test code and switches being deployed as an alternative. I find supporting different types of test to be a benefit. Seems to me if you have test infrastructure in the code that will limit options. I have seen code that activly prevented mocks that was impossible to test.