I have a couple of simple web tests that use data sources. Each web test contains only one request.
After they run it's pretty hard to detect why they failed, given that they are quite a few (80) and each has a number of rows that varies between 1 and 150.
Therefore, I used the TFS SDK to access the results programmatically, after publishing the test results to a build in TFS.
Here is the relevant part of the code:
foreach (var testRun in testRuns)
{
Console.WriteLine(string.Format("{0}", testRun.Title));
ITestCaseResultCollection testCases = testRun.QueryResults();
foreach (ITestCaseResult testcase in testCases)
{
Console.WriteLine(string.Format("{0}: {1}", testcase.TestCaseTitle, testcase.Outcome));
if (TestOutcome.Passed != testcase.Outcome)
{
Console.WriteLine(string.Format("\tNumber of iterations: {0}", testcase.Iterations.Count));
foreach (ITestIterationResult iteration in testcase.Iterations)
{
Console.WriteLine(string.Format("\t{0}: {1}", iteration.IterationId, iteration.Outcome));
}
}
}
}
The problem is that testcase.Iterations.Count is always 0. Everything else is displayed correctly. If I open the test results from Visual Studio, I can see the iterations and the details for each.
What am I missing?
Thanks.
After investigating a bit more I realized I was looking in the wrong place.
What I'm interested in is to get the details for all the rows that a databound test is running against, while ITestCaseResult.Iterations points to the iterations defined for a certain test case.
The information I'm interested in is retrieved by accessing the attachments of a test case result:
especially the ones with these types: TmiTestResultDetail TmiTestRunReverseDeploymentFiles
How to extract the information in these attachments constitutes a different question. :)