我试图从TFS的测试用例中获取结果,看起来像这样。
我似乎无法找到一种直截了当的方法。我试图直接获取工作项,查询属性但没有成功。我能够使用SDK获取数据(我试图避免)
_tfs = new TfsTeamProjectCollection(new Uri(website)) { ClientCredentials = what };
_tfs.EnsureAuthenticated();
var testService = _tfs.GetService<ITestManagementService>();
var aPoint = plan.QueryTestPoints("SELECT * FROM TestPoint WHERE TestCaseId = 10").SingleOrDefault();
console.Write(aPoint.MostRecentResultOutcome);
我从webhook获得了测试用例的ID,所以这不是问题。我想要的只是&#34; MostRecentResultOutcome&#34;。有没有办法在1次调用中从REST api获取数据?
答案 0 :(得分:0)
您还可以使用REST API下面的{{3}},它会根据您的代码信息通过测试用例ID返回测试点列表:
SELECT DISTINCT user_table.user_id
,diary_table.date_time
,user_table.NAME
FROM user_table
INNER JOIN diary_table ON user_table.user_id = diary_table.diary_user_id
AND (
date_time >= '06-Apr-2017 00:00:00'
AND date_time <= '15-Apr-2017 23:59:59'
)
AND diar_user_id IN (
SELECT DISTINCT diar_user_id
FROM diary_table
INNER JOIN event_table ON event_table.event_id = diary_table.diar_event_id
WHERE event_table.event_name = 'Lunch'
AND (
date_time >= '06-Apr-2017 00:00:00'
AND date_time <= '15-Apr-2017 23:59:59'
)
)
ORDER BY date_time ASC
,NAME
,ASC
然后将获得lastTestRun,lastResutl,results ...
的回复GET https://Fabrikam-Fiber-inc.VisualStudio.com/DefaultCollection/fabrikam-fiber-tfvc/_apis/test/plans/1/suites/1/points?testcaseid=39&api-version=1.0
答案 1 :(得分:0)
帕特里克说,你现在不能。我最终做了什么来抓取ID和System.TeamProject离开webhook那样传递
private TfsTeamProjectCollection _tfs;
private ITestManagementTeamProject _project;
private readonly ITestManagementService _service;
public TfsThing(string instanceUrl, string user, string password)
{
var cred = new VssBasicCredential(user, password);
_tfs = new TfsTeamProjectCollection(new Uri(instanceUrl)) { ClientCredentials = cred };
_tfs.EnsureAuthenticated();
_service = _tfs.GetService<ITestManagementService>();
}
public string GetTestStatus(int id, string projectName)
{
var project = _service.GetTeamProject(projectName);
var result = project.TestResults.ByTestId(id);
return result.LastOrDefault()?.Outcome.ToString();
}
这是我发现的最短路 - 虽然可能不是最有效的
如果您想知道,这些是我使用过的两个包
Install-Package Microsoft.TeamFoundationServer.Client
Install-Package Microsoft.TeamFoundationServer.ExtendedClient