Obtaining Current Build Number/Environment Settings in MTM Test Run

c#, microsoft-test-manager, tfs

Solution

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:

- Get the Latest Build

- Get Build Definitions and Build Details

- Get Detailed Build Test Results

- Get Build Settings

Problem

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.

Original source