Unit tests - The benefit from unit tests with contract changes?

前端 未结 9 1168
無奈伤痛
無奈伤痛 2021-01-30 00:27

Recently I had an interesting discussion with a colleague about unit tests. We were discussing when maintaining unit tests became less productive, when your contracts change.

9条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 00:45

    One of the rules for unit tests code (and all other code used for testing) is to treat it the same way as production code - no more, no less - just the same.

    My understanding of this is that (beside keeping it relevant, refactored, working etc. like production code) it should be looked at it the same way from the investment/cost prospective as well.

    Probably your testing strategy should include something to address the problem you have described in the initial post - something along the lines specifying what test code (including stubs/mocks) should be reviewed (executed, inspected, modified, fixed etc) when a designer change a function/method in production code. Therefore the cost of any production code change must include the cost of doing this - if not - the test code will become "third-class citizen" and the designers' confidence in the unit test suite as well as its relevance will decrease... Obviously, the ROI is in the timing of bugs discovery and fix.

提交回复
热议问题