Why is it so bad to mock classes?

前端 未结 9 1882
一向
一向 2020-12-07 17:57

I recently discussed with a colleague about mocking. He said that mocking classes is very bad and should not be done, only in few cases.

He says that only interfaces

9条回答
  •  执笔经年
    2020-12-07 18:04

    I would suggest to stay away from mocking frameworks as far as possible. At the same time, I would recommend to use mock/fake objects for testing, as much as possible. The trick here is that you should create built-in fake objects together with real objects. I explain it more in detail in a blog post I wrote about it: http://www.yegor256.com/2014/09/23/built-in-fake-objects.html

提交回复
热议问题