How can I automate creation of TFS Test Case's for each C# TestMethod Unit Test
I'm using TFS 2010, VS2010 and C#. I need to link each requirement to the unit test or tests associated with that requirement. I've found that in order to link Tests to requirements, TFS requires a Test Case for each [TestMethod] unit test. Only then can I link the Requirement to the Test Case which in turn is associated with the automated unit test. I'm looking for a way to shortcut this so that Test Cases can be created automatically for all exiting Tests. Ideally the TFS Test Case description would come from the [开发者_如何学运维TestMethod] header comments.
If you just want to create a couple of test cases, you can do it directly from Visual Studio by opening the Test Window, select your test, right-click and choose "Create Test Case From Test". You must have your test projects opened in order to see your automated tests in the Test Window.
http://msdn.microsoft.com/en-us/library/dd380741.aspx#NewTestCase
If you want to import a bunch of automated tests from a test assembly, you can use the command-line tool for Test Management, called tcm.exe (you can find it under Common7\IDE\ of your Visual Studio location). The following command will do the trick:
tcm testcase /import /storage:[test assembly] /collection:[url] /teamproject:[your team project]
You can also specify the categories or the priorities of tests you want to import. For more information, see:
http://msdn.microsoft.com/en-us/library/dd465191.aspx#CreateTestCases
Hope this helps.
精彩评论