TFS SDK 2010 – Part 5 – Create a new Test Case work item

by Ewald Hofman 11. December 2009 15:26

In Part 1 I have described how to access the Application Instance of the TFS server. This post describes how you can create a new test case based on the TestManagement capabilities. In later posts I will show what you can do more with the test management.

In order to get access to the work items, add a reference to:

  • Microsoft.TeamFoundation.TestManagement.Client
  • WindowBase (which you can find on the .Net tab in the Add Reference Dialog)

You can find the dll’s in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0

Then you have to add the following using statements:

using Microsoft.TeamFoundation.TestManagement.Client;

You can now create the work items with the following code:

// Get the work item store
ITestManagementService tms = tfai.GetTeamFoundationServer(tpc.Id).GetService<ITestManagementService>();

// Get the team project
var project = tms.GetTeamProject("Agile");

var testCase = project.TestCases.Create();
testCase.Title = "Browse my blog";

var navigateToSiteStep = testCase.CreateTestStep();
navigateToSiteStep.Title = "Navigate to \"http://www.ewaldhofman.nl\"";
testCase.Actions.Add(navigateToSiteStep);

var clickOnFirstPostStep = testCase.CreateTestStep();
clickOnFirstPostStep.Title = "Click on the first post in the summary";
clickOnFirstPostStep.ExpectedResult = "The details of the post are visible";
testCase.Actions.Add(clickOnFirstPostStep);

testCase.Save();

The result is a new test case with two steps in it:

image

Tags:

TFS SDK | VSTS 2010

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen

About the author

 

Ewald Hofman is MVP VS ALM and consultant at Avanade. His specialization is Application Lifecycle Management solutions based on Visual Studio ALM.

 

 

ClusterMap

Statistics

Statistics created at 09 Sep 2009

105 posts
130 comments
74 raters
128387 visit (351 per day)
17 users online

Recent comments

Comment RSS