Mocking values in TDD

前端 未结 2 559
别那么骄傲
别那么骄傲 2021-01-22 01:30

In the book GOOS. It is told not to mock values, which leaves me confused. Does it means that values don\'t have any behavior?

I dont\' much knowledge about the value ob

2条回答
  •  礼貌的吻别
    2021-01-22 01:44

    Quoting the linked blog post:

    There are a couple of heuristics for when a class is not worth mocking. First, it has only accessors or simple methods that act on values it holds, it doesn't have any interesting behaviour. Second, you can't think of a meaningful name for the class other than VideoImpl or some such vague term.

    The implication of the first point, in the context of a section entitled "Don't mock value objects", is that value objects don't have interesting behaviour.

提交回复
热议问题