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

后端 未结 12 2102
忘了有多久
忘了有多久 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 18:43

    BDD (Behavior Driven Development)

    Though I'm still learning, it's basically TDD organized/focused around how your software will actually be used... NOT how it will be developed/built.

    Wikipedia General Info

    BTW as far as whether to do multiple asserts per test method I would recommend trying it both ways. Sometimes you'll see where one strategy left you in a bind and it'll start making sense why you normally just use one assert per method.

提交回复
热议问题