使用QueryTestRuns()查询所有测试运行

时间:2016-06-03 18:29:17

标签: c# tfs

我正在尝试查询特定团队项目中的所有测试运行。该查询有效,但它只包含一些结果。以下是最近的运行列表。 DEV的查询正在查询,但QA的查询没有查询。可悲的是,QA是我唯一感兴趣的。

TFS Run List

以下是我目前的代码:

// Get the catalog of team project collections
CatalogNode catalogNode = configurationServer.CatalogNode;
ReadOnlyCollection<CatalogNode> tpcNodes = catalogNode.QueryChildren(
    new Guid[] { CatalogResourceTypes.ProjectCollection },
    false, CatalogQueryOptions.None);

CatalogNode teamProject = null;

// List the team project collections
foreach (CatalogNode tpcNode in tpcNodes)
{
    // Use the InstanceId property to get the team project collection
    Guid tpcId = new Guid(tpcNode.Resource.Properties["InstanceId"]);
    tpc = configurationServer.GetTeamProjectCollection(tpcId);

    if (tpc.Name == TPC_NAME)
    {
        teamProject = tpcNode;
        break;
    }
}

if (teamProject == null)
    throw new Exception(string.Format(@"Missing team project collection '{0}'", TPC_NAME));

_testManagementService = tpc.GetService<ITestManagementService>();

// Get the test runs 
IEnumerable<ITestRun> testRuns = _testManagementService.QueryTestRuns(string.Format("select * From TestRun")).OrderByDescending(x => x.DateCompleted);

foreach (var testRun in testRuns)
{
    Console.WriteLine("Test run: '{0}'", testRun.Title);
}

这是使用VS和TFS 2015。

那么为什么只有一些版本才能通过呢?还有其他一些查询方式,还是有某种我不知道的隐藏过滤器?我想看一下TFS架构,以防有另一张桌子或其他东西,但显然这是不可能的,因为微软正在警惕地保护我们自己。

2 个答案:

答案 0 :(得分:0)

您的代码没有任何问题。它似乎与安全性考虑有关:“查看测试运行”是查看所有测试对象所需的权限。如果没有此权限,用户将无法从查询中获得任何结果。绑定到Area节点的测试对象也受到Area节点权限的约束。例如,如果用户A没有对Area节点X的读取权限,则节点X中的测试对象将不会作为查询结果的一部分返回。

答案 1 :(得分:0)

我无法使用客户端库API进行分布式测试的测试运行。我使用Rest API将它们作为替代方式。