Unit Testing - What not to test

后端 未结 9 1140
悲哀的现实
悲哀的现实 2020-12-14 07:34

I have gone through a number posts on stackoverflow and numerous articles about Unit Tests. I am just trying to figure out that what I have understood is right.

9条回答
  •  遥遥无期
    2020-12-14 07:40

    I disagree with your points. You shouldn't write your unit tests based on how the code is written now, but to make sure that in the future, if another developer has changed some random part of the code, he can run them and get confidence that all is well.

    For example, you might want to test that method that simply invokes another. After all you are only interested that the outer method works, not how it works. If the next developer changes the outer method so that is not so simple anymore, he will be missing a unit test.

    This is the reason why you should use a tool like NCover to make sure that 100% of your code is executed in the unit tests!

提交回复
热议问题