How many unit tests should I write per function/method?

后端 未结 12 2129
忘了有多久
忘了有多久 2020-12-05 18:36

Do you write one test per function/method, with multiple checks in the test, or a test for each check?

12条回答
  •  不知归路
    2020-12-05 19:05

    I have a test per capability the function is offering. Each test may have several assertions, however. The name of the testcase indicates the capability being tested.

    Generally, for one function, I have several "sunny day" tests and one or a few "rainy day" scenario, depending of its complexity.

提交回复
热议问题