How to re-deploy, re-create database on each test run

前端 未结 3 963
鱼传尺愫
鱼传尺愫 2021-01-05 14:11

Currently I\'m using Visual Studio 2012 RC and SQL Server 2012 RTM.

I\'d like to know how to re-deploy/re-create a test database for each test run.

Keep in m

3条回答
  •  滥情空心
    2021-01-05 14:49

    The fastest solution, while a bit of a hack, is really straightforward. You can set the DB Projects properties under the debugging tab to "always re-created DB". Then test in two clicks, do a debug/build, then run all tests. You should get a freshly built DB on localDB for you tests to be ran against. You can also change the target for the debugging DB (again the DB projects properties) to whatever you want, so you can deploy to a .dacpac, or to an existing SQL DB or wherever. It means testing in two steps, and if your build is long, it may be annoying, but it works. Otherwise, I believe scripting is your only option.

提交回复
热议问题