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

后端 未结 12 2132
忘了有多久
忘了有多久 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:56

    I try to separate out Database tests and Business Logic Tests (using BDD as others here recommend), running the Database ones first ensures your Database is in a good state before asking your application to play with it.

    There's a good podcast show with Andy Leonard on what it involves and how to do it, and if you'd like a bit more information, I've written a blog post on the subject (shameless plug ;o)

提交回复
热议问题