How to copy a Visual Studio database unit test -


I am writing unit tests for procedures stored in VSTE for database professionals, and some of the pre-existing test cases I want to make a copy which needs to be modified only in some places. It will be very tedious to manually re-create them. I did not find any solution either on the web or in books. Any ideas would be welcome.

This is definitely not easy, but this is the best way I've found.

This method assumes that 1 or more tests in each test file target the same database object (formerly: PipelTest CPS runs a test against the public table; spGetPeopleTest The .cs targets stored procedure spGetPeople goal ...) makes it easy (for example you copy a PeopleTest.cs file and all "people" references are renamed "jobs").

  1. In the Solution Explorer, copy-paste the unit test file, rename the new file.
  2. Right-click on the new file and select the code to open the C # / VB code file.
  3. Replace all in the code file. For example if the original test references a work table and you want your new test to refer to your local table, replace "work" with "people".
  4. In the Solution Explorer, expand the new test file to expand .resx file (this is where the SQL code is stored.) Right-click the .resx file, select Open With, then Select XML Editor.
  5. Change this file to all.
  6. Save all, then reopen the test in the designer and your new test is ready to go.

Comments