Note that there are some explanatory texts on larger screens.

plurals
  1. POIn TFS API, how do I get the full class name for a given test?
    text
    copied!<p>I have an <a href="http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.testmanagement.client.itestcaseresult.aspx" rel="nofollow"><code>ITestCaseResult</code></a> object in hand and I can't figure out how to extract the Test Class information from it. The object contains the test method's name in the <code>TestCaseTitle</code> property but there are a lot of duplicate titles across our code base and I would like more information.</p> <p>Assuming I have <code>Foo.Bar</code> assembly with class <code>Baz</code> and method <code>ThisIsATestMethod</code>, I currently only have access to the <code>ThisIsATestMethod</code> information from the title, but I would like to obtain <code>Foo.Bar.Baz.ThisIsATestMethod</code>.</p> <p>How can I do that using the TFS API?</p> <p>Here's some stripped down code:</p> <pre><code>var def = buildServer.CreateBuildDetailSpec(teamProject.Name); def.MaxBuildsPerDefinition = 1; def.QueryOrder = BuildQueryOrder.FinishTimeDescending; def.DefinitionSpec.Name = buildDefinition.Name; def.Status = BuildStatus.Failed | BuildStatus.PartiallySucceeded | BuildStatus.Succeeded; var build = buildServer.QueryBuilds(def).Builds.SingleOrDefault(); if (build == null) return; var testRun = tms.GetTeamProject(teamProject.Name).TestRuns.ByBuild(build.Uri).SingleOrDefault(); if (testRun == null) return; foreach (var outcome in new[] { TestOutcome.Error, TestOutcome.Failed, TestOutcome.Inconclusive, TestOutcome.Timeout, TestOutcome.Warning }) ProcessTestResults(bd, testRun, outcome); </code></pre> <p>...</p> <pre><code>private void ProcessTestResults(ADBM.BuildDefinition bd, ITestRun testRun, TestOutcome outcome) { var results = testRun.QueryResultsByOutcome(outcome); if (results.Count == 0) return; var testResults = from r in results // The "r" in here is an ITestCaseResult. r.GetTestCase() is always null. select new ADBM.Test() { Title = r.TestCaseTitle, Outcome = outcome.ToString(), ErrorMessage = r.ErrorMessage }; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload