2 -6ren">
gpt4 book ai didi

c# - 通过数据仓库以编程方式检索 TFS "instrumented binaries"的路径信息

转载 作者:太空宇宙 更新时间:2023-11-03 11:23:11 25 4
gpt4 key购买 nike

有谁知道如何以编程方式(使用 TFS API)确定将哪些二进制文件设置为作为 T​​FS 构建的一部分进行检测?

例如,在 TFS 上运行具有代码覆盖率的构建后,它会在输出中显示:

...
-> 2 binaries instrumented - 62% of all code blocks covered
SomeAssembly.dll - 392 blocks covered, 368 blocks not covered
SomeExe.exe - 584 blocks covered, 241 blocks not covered
...

我想以编程方式确定“SomeAssembly.dll”和“SomeExe.exe”是作为该构建的一部分进行检测的二进制文件。

我已经通过 TFS API 检索团队项目,但我不确定是否可以让我到达我想去的地方:

TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(versionControlURIRoot + defaultProjectDirectory))
var testManagementService = collection.GetService<ITestManagementService>();
ITestManagementTeamProject teamProject = testManagementService.GetTeamProject(projectName);

最佳答案

解决方法如下:

获取团队项目:

TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(versionControlURIRoot + defaultProjectDirectory));
var testManagementService = collection.GetService<ITestManagementService>();
ITestManagementTeamProject teamProject = testManagementService.GetTeamProject(projectName);

从 Build Coverage 元数据中提取程序集名称:

List<string> assemblyNames = new List<string>();
if (teamProject != null) {
ICoverageAnalysisManager coverageAnalysisManager = teamProject.CoverageAnalysisManager;
if (coverageAnalysisManager != null) {
IBuildCoverage[] buildCoverage = coverageAnalysisManager.QueryBuildCoverage(buildURI, CoverageQueryFlags.Modules);
List<string> assemblyNames = new List<string>();
foreach (IBuildCoverage buildCoverageDetails in buildCoverage) {
foreach (IModuleCoverage module in buildCoverageDetails.Modules) {
assemblyNames.Add(module.Name);
}
}
}
}

关于c# - 通过数据仓库以编程方式检索 TFS "instrumented binaries"的路径信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10251775/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com