views:

14

answers:

1

I'm writing unit tests for stored procedures in VSTE for Database Professionals, and want to copy some already existing test cases that only need to be modified in a few places. Manually re-creating them would be very tedious. I couldn't find a solution either on the web or in books. Any ideas are welcome.

+1  A: 

It's definitely not easy but here is the best method that I've found. This method assumes that the tests differ only by object name, though when you're through with the steps you'll be able to make other tweaks as needed.

  1. In Solution Explorer, copy-paste the unit test file. Rename the new file.
  2. Right-click the new file and select View Code to open the C#/VB code file.
  3. Perform a Replace All in the code file. For example if the original test referenced a Tasks table and you want your new test to reference a People table, replace "Tasks" with "People".
  4. In Solution Explorer, expand the new test file to expose the .resx file. (This is where the SQL code is stored.) Right-click the .resx file, select Open With, then select XML Editor.
  5. Perform the same Replace All in this file.
  6. Save all, then re-open the test in the designer and your new test is ready to go.
Keith