如何检索当前通过TFS(vNext)构建运行的测试用例ID? [英] How to retrieve a Test Case ID that is currently running through TFS (vNext) build?

查看:101
本文介绍了如何检索当前通过TFS(vNext)构建运行的测试用例ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TFS 2013中,当从MTM运行测试时,我们可以通过使用TestContext属性字典来获取当前正在运行的测试用例的ID,如下所示:

In TFS 2013 when running tests from MTM, we were able to get the ID of the currently running test case by using the TestContext Properties dictionary as follows:

var testCaseID = TestContext.Properties ["__ Tfs_TestCaseId __"].ToString();

如果测试是作为TFS vNext build(BDT)的一部分运行的,则此语句返回NULL.

This statement returns NULL if tests are being run as part of TFS vNext build (BDT).

为了更新测试结果中的某些字段(例如注释/注释),我需要知道当前测试运行和测试用例的ID.如何退回该信息?

In order to update some fields in test results for instance Comments/Notes, I will need to know the ID of the current test run and test case. How can I return that information?

我正在内部使用TFS 2017.

I am using TFS 2017 on-premise.

谢谢!

推荐答案

在TestMethod中运行测试时,可以获取测试用例标识符. 您可以通过使用TFS API查询TFS来获取它.您可以从C#代码中找到当前正在运行的测试用例运行的测试结果对象,以实现此目的. 您将从testContext获取当前的测试运行ID.

It is possible to get the Test Case Identifier while test is running in TestMethod. You can get it by querying TFS using TFS API. You can do that from your C# code by finding the test results object for current running test case run. You will get the current test run ID from the testContext.

这篇关于如何检索当前通过TFS(vNext)构建运行的测试用例ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆