【发布时间】:2019-07-23 05:25:49
【问题描述】:
我正在尝试在 .NET 中尽可能简单地在 CSV 输入中创建测试结果,看起来最快的方法是首先创建一个空的测试运行,然后将新的测试结果添加到测试中跑。
我已经通过硬编码和运行 Postman 进行了测试,但似乎通过 REST 和 SDK 都收到了相同的错误消息:
必须为自动测试运行指定 AutomatedTestName 未指定 TestPointId 和 TestCaseId。
这是 .NET 代码:
var testCase = await testPlanClient.GetTestCaseAsync(_teamProject, {planId}, {suiteId}, "1141");
var testPoint = testCase[0].PointAssignments.SingleOrDefault(p => p.ConfigurationId == testConfiguration.Id);
var pointId = testPoint.Id;
var run = new RunCreateModel(name: testRun.Name, state: "NotStarted", isAutomated: false, plan: new ShallowReference({planid}), pointIds:new int[] { 1654 });
...
testResultList.Add(new TestApi.TestCaseResult()
{
TestCaseTitle = testResult.TestCaseTitle,
TestCase = new ShallowReference(id: testResult.TestCaseId.ToString()),
TestPoint = new ShallowReference(id: "1654"),
TestCaseReferenceId = testResult.TestCaseId,
Outcome = SetOutcome(testResult.Outcome),
Configuration = new ShallowReference(id: testConfiguration.Id.ToString()),
CreatedDate = testResult.CreatedDate,
StartedDate = testResult.StartedDate,
CompletedDate = testResult.CompletedDate
});
}
List<TestApi.TestCaseResult> createdTestResults = new List<TestApi.TestCaseResult>();
createdTestResults = await testClient.AddTestResultsToTestRunAsync(testResultList.ToArray(), _teamProject, testRunId);
邮递员:
POST https://dev.azure.com/{org}/{project}/_apis/test/Runs/{runId}/results?api-version=5.1
[
{
"testCaseTitle": "testcase1",
"testPoint": {
"id": 17
},
"testCase": {
"id": 1141
},
"priority": 1,
"outcome": "Passed"
}
]
我在上面的示例中同时输入了 TestPointId 和 TestCaseId,如果我仍然收到相同的错误消息,两者似乎都不起作用。我查看了类似的答案,例如:How to Add test results to a test run in VSTS using Rest API programatically,但它们似乎都在使用现有的测试结果,我只想在运行中添加新的测试结果。有任何想法吗?
【问题讨论】:
标签: c# .net azure-devops azure-devops-rest-api tfs-sdk