Monday, March 7, 2011

TFS 2010 TCM - Importing the test cases along with the Area and Iteration paths

With tcm.exe, you can import test cases from your test code. You can pass the test assembly to tcm and it will create new test cases or update existing test cases for each TestMethod. The command for importing the test cases is:

tcm testcase /import /collection:teamprojectcollectionurl /teamproject:project
             /storage:path
             [/maxpriority:priority]
             [/minpriority:priority]
             [/category:filter]
             [/syncsuite:id [/include]]
             [/login:username,[password]]

Also refer http://msdn.microsoft.com/en-us/library/ff942471.aspx

Consider a scenario where you created 10 TestMethods and use tcm to import the test cases. 10 new test cases are created in this case.
You realize that you need to update the Area property of these test cases. Hence you open them in excel and update the Area in one shot.
Now you add 5 more TestMethods and use tcm to import the test cases. 5 new test cases are created in this case. Howevere, along with creating new test cases, the older 10 test cases are updated and the Area property is reseted. So you have to again open all the test cases in excel and update the Area.

In order to make sure that your new test case get the Area assigned while they are imported and you dont loose the Area of exisitng test cases, you can add the following attribute to the TestMethods:
[CssProjectStructure("vstfs:///Classification/Node/<guid>")]
 You can find the guid from Tfs_Warehouse
select AreaGUID from DimArea where AreaPath='...'

Similarly, if you want to update the Iteration, you can use
[CssIteration("vstfs:///Classification/Node/<guid>")]
You can find the guid from Tfs_Warehouse
select IterationGUID from DimIteration where IterationPath='...'

Similarly, you could add other supported attributes to the TestMethods to make sure that they are imported.

4 comments:

  1. Thanks for all your help in TFS area.
    How did we find out GUID for a CustomField say "Application" using API's?

    Thanks In Advance
    Pravesh

    ReplyDelete
  2. The easiest way is to query Tfs_Warehouse http://msdn.microsoft.com/en-us/library/ms244696(v=VS.80).aspx

    ReplyDelete
  3. Can this be done using tfs API's?

    ReplyDelete
  4. You can find the the Area/Iteration nodes using TFS API, see http://geekswithblogs.net/TarunArora/archive/2011/07/10/tfs-2010-sdk-get-projects-iterations-area-path-queries-and.aspx

    ReplyDelete