Should I unit-test with data that should not be passed in a function (invalid input)?

后端 未结 7 1171
执笔经年
执笔经年 2021-01-17 22:20

I am trying to use TDD for my coding practice. I would like to ask should I test with a data that should not happen in a function BUT this data may possibly break your progr

7条回答
  •  悲哀的现实
    2021-01-17 23:14

    You said your method will raise an exception if the argument is not valid.

    So, yes you should, because you should test that the exception gets raised.

提交回复
热议问题