Mocking vs. Test DB?

前端 未结 8 2092
无人及你
无人及你 2020-12-29 20:44

Earlier I asked this question How to correctly unit test my DAL?, one thing left unanswered for me is if to really test my DAL is to have a Test DB, then what is the role of

8条回答
  •  暖寄归人
    2020-12-29 21:31

    Putting unit tests into transactions that roll back sounds hacky. Instead of that I have code that cleans the database of any crud (i.e. anything that isn't static/reference data) before the tests run (i.e. in the constructor of my test class). When your tests fail it helps to have the data still in the database to inspect what the cause of the failure is.

提交回复
热议问题