Should you Unit Test simple properties?

前端 未结 8 1371
耶瑟儿~
耶瑟儿~ 2021-02-01 13:22

Should you Unit Test simple properties of a class, asserting that a value is set and retrieved? Or is that really just unit testing the language?

Example

8条回答
  •  终归单人心
    2021-02-01 13:36

    I would have to say no. If that doesn't work, you have bigger problems. I know I don't. Now some will argue that having the code alone would make sure the test failed if the property was removed, for example. But I'd put money on the fact that if the property were removed, the unit test code would get removed in the refactor, so it wouldn't matter.

提交回复
热议问题