Mocking for integration tests

后端 未结 3 1899
死守一世寂寞
死守一世寂寞 2021-01-30 13:05

How does one mock the many dependencies needed for integration tests?

I use Mockito for my \'pure\' unit tests. \'Pure\' in this case means testing a single class, mock

3条回答
  •  太阳男子
    2021-01-30 13:53

    Great question.

    It seems like you hit the limits of Mockito. Mockito is great if what you want to inspect object interactions.

    What you want, though, seems to be observability (and controllability) at a higher level of abstraction. I'm afraid that the mocks or stubs you need for that should be carefully designed and hand-crafted.

    At the unit level, these mocks can be nicely generated, by means of Mockito. At the integration level, this becomes much harder, and you will need purpose made testability interfaces.

提交回复
热议问题