Getting current build / environment numbers in the MTM test run

I am trying to find a way to access the current build number and / or current environment settings from MTM so that the test suite runs as part of the build. I want to use this information in my own reports, as the information provided by MTM does not display everything I need.

Who succeeded? I read a lot of posts about people's attempts, but they all seem to end in dead ends or Test Scribe, which simply outputs the same data to word doc and is quite limited (there is no custom file path to save and is not executed during tests) .

Unfortunately, I have no code to represent what I tried, as I was not even close. Although I looked rather closely at TestContext in VisualStudio2010, and it does not seem to take a lot of MTM information outside of the current test system.

+4
source share
2 answers

You can use the TFS API for this .

We have implemented an external project (not as part of the command assembly), which tells TestResults TestRun , passing TestRunId or BuildNumber as parameters. I think if you use it as part of an assembly, you can somehow pass it as a parameter at runtime or just get the latest assembly.

For more information, you can check the following links:

+7
source

Hi, you can use the following code to get the plan and detail in 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); 
0
source

Source: https://habr.com/ru/post/1414831/


All Articles