Any opinions on mock tests how deep should you mock logic of a single component?

I am convinced that you only should shallow mock your components.

However there seems to be some component structures out there that require much deeper mocking

  • 0
    I mock if I have something that acts outside the tests memory.
    So if I need something from the disk, network or sensors
  • 0
    Component is a broad term. For UI tests, I generally do them in integrated e2e fashion. For methods, I'll test the public interface with a staged mockup for all happy path conditions and then edge cases.

    My preferred approach is to run through a series of escalating processes that represent usage flows so you're exercising the system in a natural way.
  • 0
    If you're referring to mocked web apps like Sandbox, there's a huge difference between deep mocks (cumbersome, costly, rock headed stupid... the sort of thing contract QAs do to justify their existance) and broad mocks, where some condition (such as particular input, rather than latent state) gives rise to a wide variety of behaviour. Above all, they are and must be individually shallow. Mocks must be economical, easily groked and easily modified, which deep mocks will never be.
Add Comment