You could get test run of the build first and then retrieve the test result from the test run:
class Program
{
static void Main(string[] args)
{
string ur = "https://xxxxxxx/";
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(ur));
//Get build information
BuildHttpClient bhc = ttpc.GetClient<BuildHttpClient>();
string projectname = "Project";
int buildId = x;
Build bui = bhc.GetBuildAsync(projectname,buildId).Result;
//Get test run for the build
TestManagementHttpClient ithc = ttpc.GetClient<TestManagementHttpClient>();
Console.WriteLine(bui.BuildNumber);
QueryModel qm = new QueryModel("Select * From TestRun Where BuildNumber Contains '" + bui.BuildNumber + "'");
List<TestRun> testruns = ithc.GetTestRunsByQueryAsync(qm,projectname).Result;
foreach (TestRun testrun in testruns)
{
List<TestCaseResult> testresults = ithc.GetTestResultsAsync(projectname, testrun.Id).Result;
foreach (TestCaseResult tcr in testresults)
{
Console.WriteLine(tcr.Id);
Console.WriteLine(tcr.Outcome);
}
Console.ReadLine();
}
Console.ReadLine();
}
}
あなたが失敗したテスト結果IDを取得したら、あなたはRest API to attach a file to test resultを使用することができます。
POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results/{result}/attachments?api-version={version}
Content-Type: application/json
{
"stream": { string },
"fileName": { string },
"comment": { string },
"attachmentType": { string }
}
あなたはSpecflow&セレンでテストを書きましたか? –