Scala: Mocking and the Cake Pattern

后端 未结 4 900
梦如初夏
梦如初夏 2021-02-03 11:32

I\'ve been trying to adopt the Cake Pattern but I\'m having difficulties adapting to this programming styles, especially where unit tests are concerned.

Lets assume that

4条回答
  •  你的背包
    2021-02-03 11:59

    It's a good question. We came to the conclusion it can't be done, at least not quite the same way we're used to. It's possible to use stubs instead of mocks and mix the stubs in cake-wise. But this is more work than using mocks.

    We have two Scala teams and one team adopted the cake pattern, using stubs instead of mocks, whilst the other team stuck to classes and dependency injection. Now I've tried both, I prefer DI with mocks due to it being simpler to test. And arguably simpler to read too.

提交回复
热议问题