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.
- In Solution Explorer, copy-paste the unit test file. Rename the new file.
- Right-click the new file and select View Code to open the C#/VB code file.
- 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".
- 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.
- Perform the same Replace All in this file.
- Save all, then re-open the test in the designer and your new test is ready to go.
Keith
2010-10-25 14:24:21