次の方法で共有


How can I configure MTLM to use my custom bug / test case type?

How can I configure MTLM to use my custom bug / test case type?  

I got this Q on my previous blog and thought of posting a separate post on it as it's a bit tricky to do it and hence other folks may need this info.

In Microsoft Test and Lab Manager (MTLM), we don’t provide any UI way to set a particular work item type as default work item type for a category. Basically, if I’ve added a new bug type say “CustomBug” to TFS and want MTLM to refer to that type always while opening a new bug etc then there is no UI way to achieve it.

But yes, you can do it through witadmin using importcategories / exportcategories command.

First you need to exports the XML definition of categories defined on the Team Foundation Server by using exportcategories command e.g.

The following command exports the work item type categories defined for the AdventureWorks project to the Categories XML file:

C:\Program Files\Microsoft Visual Studio 10.0\VC>witadmin exportcategories /collection:"https://AdventureWorksServer:8080/AWTeam/Collection1

/p:AdventureWorks /f:"Categories.xml"

Categories.xml will look this:

<?xml version="1.0" encoding="utf-8"?>

<cat:CATEGORIES xmlns:cat="https://schemas.microsoft.com/VisualStudio/2008/workitemtracking/categories">

  <CATEGORY refname="Microsoft.BugCategory" name="Bug Category">

    <DEFAULTWORKITEMTYPE name="Bug" />

  </CATEGORY>

  <CATEGORY refname="Microsoft.RequirementCategory" name="Requirement Category">

    <DEFAULTWORKITEMTYPE name="User Story" />

  </CATEGORY>

  <CATEGORY refname="Microsoft.SharedStepCategory" name="Shared Step Category">

    <DEFAULTWORKITEMTYPE name="Shared Steps" />

  </CATEGORY>

  <CATEGORY refname="Microsoft.TestCaseCategory" name="Test Case Category">

    <DEFAULTWORKITEMTYPE name="Test Case" />

  </CATEGORY>

</cat:CATEGORIES>

As you can see that there is default work item type for each category like Bug, Test Case, Shared Step.

You just need to modify the xml file so as to point DEFAULTWORKITEMTYPE of required category to yours newly created work item type. E.g. If I want to use work item type CustomBug as default work item type for Bug category then my modified XML will look like this:

<?xml version="1.0" encoding="utf-8"?>

<cat:CATEGORIES xmlns:cat="https://schemas.microsoft.com/VisualStudio/2008/workitemtracking/categories">

  <CATEGORY refname="Microsoft.BugCategory" name="Bug Category">

    <DEFAULTWORKITEMTYPE name="CustomBug" />

  </CATEGORY>

  <CATEGORY refname="Microsoft.RequirementCategory" name="Requirement Category">

    <DEFAULTWORKITEMTYPE name="User Story" />

  </CATEGORY>

  <CATEGORY refname="Microsoft.SharedStepCategory" name="Shared Step Category">

    <DEFAULTWORKITEMTYPE name="Shared Steps" />

  </CATEGORY>

  <CATEGORY refname="Microsoft.TestCaseCategory" name="Test Case Category">

    <DEFAULTWORKITEMTYPE name="Test Case" />

  </CATEGORY>

</cat:CATEGORIES>

After that you just need to import this XML back into team project of TFS using importcategories. e.g. The following example imports categories from the myCategories XML file to the AdventureWorks project:

C:\Program Files\Microsoft Visual Studio 10.0\VC>witadmin importcategories /collection:"https://AdventureWorksServer:8080/AWTeam/Collection1

/p:AdventureWorks /f:"Categories.xml"

Now if you open any bug in Test Runner / MTLM then it will open your CustomBug work item type form instead of default bug form. Similarly you can do required changes to use customized Test Case / any other work item.

Required Permissions
For the team project where the work item types are defined, you must have the following permissions set:

· To export categories of work item types, you must be a member of the Readers group or have your View work items in this node permission set to Allow

· To import categories of work item types, you must be a member of the Team Foundation Administrators security group or the Project Administrators security group.

For more details on TFS permissions check here

Comments

  • Anonymous
    March 31, 2010
    thakns this is awesome! any way to auto populate specific fields in the custom work item?