I don't like mocking

San Francisco

When starting out on adding something new to a project that one is not intimately familiar with (or even on one with which one is), the first thing is to write the description of some small test. Just a sentence or two about what is to be tested and why the expected results are what they are. The test doesn't have to do much, or even be very unique, but it should start from nothing and build up whatever is required. For this reason, I often find integration tests to be much easier to write and to keep within the conceptual model of the system.

The thing with mocked components is that they assume you know enough about what those components do to construct their output manually, and often that's not the case. So, I resort to the full real components quite often in tests, with the only downside being the speed of tests.

Retrieved from ‘https://samwilson.id.au/index.php?title=I_don%27t_like_mocking&oldid=2159