Nashibukasan
Nashibukasan

Reputation: 2028

Obtaining Current Build Number/Environment Settings in MTM Test Run

I have been trying to find a way to access the current Build Number and/or the current Environment Settings from MTM for a test suite run as part of a build. I wish to use this information within my own custom reports as the information provided by MTM does not capture everything I require.

Anyone been able to achieve this? I have read many posts of people trying, but they all seem to end at dead ends or Test Scribe, which just outputs the same data in a word doc and is fairly restricted (no custom filepath to save to, and is not run during tests).

Unfortunately I have no code to present what I have tried as I have not even been close. Though I have looked at TestContext in VisualStudio2010 quite closely and it does not appear to pick up much MTM info outside of the current TestCase being run.

Upvotes: 4

Views: 1789

Answers (2)

user2861354
user2861354

Reputation: 41

Hi you can use the following code to get the plan and build details through MTM

WorkItemStore workitemstore = tfsserv.GetService<WorkItemStore>();
        Project tfsproject = workitemstore.Projects[tfsprojectname];
        ITestManagementService Mtmserveice = (ITestManagementService)tfsserv.GetService(typeof(ITestManagementService));
        ITestManagementTeamProject mtmproj = Mtmserveice.GetTeamProject(tfsproject.Name);

        ITestPlan plan = mtmproj.TestPlans.Find(planid);
        Console.WriteLine("Test Plan: {0}", plan.Name);
        Console.WriteLine("Plan ID: {0}", plan.Id);
        Console.WriteLine("Build Currently In Use: {0}", plan.BuildNumber);

Upvotes: 0

chaliasos
chaliasos

Reputation: 9793

You can use the TFS API for that.

We have implemented an external project (not as part of a team build) which is reporting the TestResults of a TestRun by passing as parameters the TestRunId or the BuildNumber. I think that if you use it as part of a build you will be able somehow to pass it as parameter on runtime or just get the latest Build.

You can check the following links for further details:

Upvotes: 7

Related Questions