There are probably many opinions on this sort of question, so you are unlikely to get certainty ;-)
'Thin' or 'dumb' objects with no real functionality may not deserve their own tests (only test things that can actually go wrong). So a combined unit test would be OK.
I would add unit tests for the model layer objects if they grow in complexity/functionality, because finer-grained, localised tests will localise any failures better, and are more likely to run fast and therefore be run frequently.
If you have any coarser-grained end-to-end or 'integration' tests, then these will give some coverage of both kinds of object and may pick up trivial errors missed by the absence of dedicated unit tests... but it's a calculated risk / judgement.
发布评论
评论(1)
对于这类问题可能有很多意见,所以你不太可能得到确定性;-)
没有实际功能的“薄”或“哑”对象可能不值得自己测试(只测试实际上可能出错的东西)。所以组合单元测试就可以了。
如果模型层对象的复杂性/功能增加,我会为它们添加单元测试,因为更细粒度的本地化测试将更好地定位任何故障,并且更有可能快速运行,因此可以频繁运行。
如果您有任何粗粒度的端到端或“集成”测试,那么这些测试将覆盖两种类型的对象,并且可能发现由于缺乏专用单元测试而遗漏的微不足道的错误...但这是经过计算的风险/判断。
There are probably many opinions on this sort of question, so you are unlikely to get certainty ;-)
'Thin' or 'dumb' objects with no real functionality may not deserve their own tests (only test things that can actually go wrong). So a combined unit test would be OK.
I would add unit tests for the model layer objects if they grow in complexity/functionality, because finer-grained, localised tests will localise any failures better, and are more likely to run fast and therefore be run frequently.
If you have any coarser-grained end-to-end or 'integration' tests, then these will give some coverage of both kinds of object and may pick up trivial errors missed by the absence of dedicated unit tests... but it's a calculated risk / judgement.