Link Defect Work Item with Microsoft Test Manager (MTM) 2010

Posted by: Subodh Sohoni , on 9/5/2011, in Category Visual Studio, VSTS & TFS
Views: 53100
Abstract: In this article, we will see how to link ‘Defect’ work item with Microsoft Test Manager 2010 and how to Create Custom Queries based upon the ‘Defect’ work item type.

In the first two parts of series of articles on Customize work item type definition in TFS 2010, we have seen how to edit work item type definition and save it in the TFS 2010. In this article, we will see how to link ‘Defect’ work item with Microsoft Test Manager 2010 and how to Create Custom Queries based upon the ‘Defect’ work item type.

As in
previous articles, we will do the walkthrough using the virtual machine created by Brian Keller. You can download it over here. Whatever we did in the first two walkthroughs, is a prerequisite for this one and if you have not done those walkthroughs, then I suggest you to go back to first two parts of this series and complete those walkthroughs before starting this one.

We will start this walkthrough by checking that Microsoft Test Manager 2010 as yet has no awareness of Defect work item type.

 



Step 1: Open Microsoft Test Manager 2010 from Start – Programs – Microsoft Visual Studio 2010 – Microsoft Test Manager 2010

Step 2: Expand Computer name, Default Collection and select team project – Tailspin Toys

tfs-team-project

and click on Connect now.

Step 3: Select Iteration 2 test plan and click Select Plan

select-test-plan

Step 4: In the Test activity of MTM 2010, select the test suite “7: As a customer I should be able to remove items from my shopping cart” and the testcase 3 “Entering invalid data …..” under that.

Click on the Run button. Do not overwrite on the existing recording. Start Test.

select-test-suite

Step 5: Test runner starts. Do not execute any step. Click on Create Bug button. The bug work item form is opened, what we want is Defect work item to open.

create-new-bug

Now we will configure TFS in such a way that MTM 2010 will treat that as standard work item type to instantiate when tester clicks the button to create Bug while testing.

Step 6: Go to the Command Prompt from Visual Studio 2010 menu. Right click on it and select Run as Administrator. Type following command in it:

witadmin exportcategories /collection:http://localhost:8080/tfs/defaultcollection /p:"Tailspin Toys" /f:"C:\WITD\Categories.xml"

Change the code of the created XML file to :

<?xml version="1.0" encoding="utf-8"?>
<cat:CATEGORIES xmlns:cat="http://schemas.microsoft.com/VisualStudio/2008/workitemtracking/categories">
<CATEGORY refname="Microsoft.BugCategory" name="Bug Category">
<DEFAULTWORKITEMTYPE name="Defect" />
<WORKITEMTYPE 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>


Import the categories back into TFS by using the command:

witadmin importcategories /collection:http://localhost:8080/tfs/defaultcollection /p:"Tailspin Toys" /f:"C:\WITD\Categories.xml"

Following procedure is also

Open Microsoft Test Manager 2010 from Start – Programs – Microsoft Visual Studio 2010 – Microsoft Test Manager 2010 Expand Computer name, Default Collection and select team project – Tailspin Toys and click on Connect now. Select Iteration 2 test plan and click Select Plan In the Test activity of MTM 2010, select the test suite “7: As a customer I should be able to remove items from my shopping cart” and the testcase 3 “Entering invalid data …..” under that. Click on the Run button. Do not overwrite on the existing recording. Start Test. Test runner starts. Do not execute any step. Click on Create Bug button. The bug work item form is opened, what we want is Defect work item to open. Now we will configure TFS in such a way that MTM 2010 will treat that as standard work item type to instantiate when tester clicks the button to create Bug while testing. Go to the Command Prompt from Visual Studio 2010 menu. Right click on it and select Run as Administrator. Type following command in it: Change the code of the created XML file to : Import the categories back into TFS by using the command: Following procedure is also suggested by msdn and some other websites. I have found that it does not work as of this writing and Microsoft recently has accepted that as a bug in the product. Please do not follow that process (steps 7 to 10).

TCM is the tool that is used for configuring the Test Case Management done through MTM 2010. Now we will use that tool to get the configuration of MTM 2010 (in the context of Bug creation) in the XML file and make modification in it and then import it back.

Step 7: Execute the command:

TCM bugfieldmapping /export /mappingfile:c:\WITD\bugmap.xml
/collection:http://localhost:8080/tfs/DefaultCollection /teamproject:"Tailspin Toys"


Step 8: Open the created bugmap.xml file. Following xml is located in the file

<?xml version="1.0" encoding="utf-16"?>
<BugFilerMappings workitemtypetocreate="Bug">
<ReproSteps>Microsoft.VSTS.TCM.ReproSteps</ReproSteps>
<SystemInformation>Microsoft.VSTS.TCM.SystemInfo</SystemInformation>
<BuildFoundIn>Microsoft.VSTS.Build.FoundIn</BuildFoundIn>
</BugFilerMappings>

 

Step 9: Change the tag <BugFilerMappings workitemtypetocreate="Bug"> to <BugFilerMappings workitemtypetocreate="Defect">

Step 10: TCM bugfieldmapping /import /mappingfile:c:\WITD\bugmap.xml
/collection:http://localhost:8080/tfs/DefaultCollection /teamproject:"Tailspin Toys"


You may now continue execution from Step 11.

Step 11: Re-execute the steps 4 and 5. This time you will see that Defect work item is created instead of Bug work item. If it does not appear then it may be because the data is held in cache. Close and reopen the MTM 2010 and continue.

defect-work-item

Step 12: Give a title to defect, set the division to New Projects. Save and close that defect.

Now we will create a query that lists all defects in a particular Division.

Step 13: Open the Track activity in MTM 2010. Select My Queries folder and click on New Query button. In the query designer that opens, in the first clause set Work Item Type = Defect and in the next row add the clause Division = New Projects.

mtm-track-activity

Run the query and you should see the defect that you had saved in step 12. You may save and close the query.

Summary: In this third and the last article in the series for showing how to customize work item type definition, we have seen the effect of creating a work item type definition that replaces Bug work item. We need to make the related software like MTM, aware of the new work item type and also create new queries taking care of that new work item type.

Give a +1 to this article if you think it was well written. Thanks!
Recommended Articles
Subodh Sohoni, Team System MVP, is an MCTS – Microsoft Team Foundation Server – Configuration and Development and also is a Microsoft Certified Trainer(MCT) since 2004. Subodh has his own company and conducts a lot of corporate trainings. He is an M.Tech. in Aircraft Production from IIT Madras. He has over 20 years of experience working in sectors like Production, Marketing, Software development and now Software Training. Follow him on twitter @subodhsohoni


Page copy protected against web site content infringement by Copyscape


User Feedback
Comment posted by Scott on Thursday, October 11, 2012 9:57 PM
We are having a problem creating a link to Microsoft Test Manager items from Sharepoint because share point will not recognize mtm://  urls.  Any ideas we can try?

Post your comment
Name:  
E-mail: (Will not be displayed)
Comment:
Insert Cancel