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

前端 未结 9 1172
無奈伤痛
無奈伤痛 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:35

    It's better to have to fix unit test that fail due to intentional code changes than not having tests to catch the bugs that are eventually introduced by these changes.

    When your codebase has a good unit test coverage, you may run into many unit test failures that are not due to bugs in the code but intentional changes on the contracts or code refactoring.

    However, that unit test coverage will also give you confidence to refactor the code and implement any contract changes. Some test will fail and will need to be fixed, but other tests will eventually fail due to bugs that you introduced with these changes.

提交回复
热议问题