Recreate and Reseed LocalDb Before Each Unit Test

后端 未结 3 2048
刺人心
刺人心 2020-12-14 11:22

I\'m attempting to write unit/integration tests for my ASP.NET Web API project and struggling to run each test in isolation. Allow me to explain.

I have a *.testset

3条回答
  •  自闭症患者
    2020-12-14 11:46

    I would suggest re-creating your database before you begin your tests and then wrap each in a transaction that always rolls back. This is quite beneficial if your recreate stage takes a lot of time to complete (e.g. because of the actions that need to be performed, etc.).

提交回复
热议问题