How to retrieve a Test Case ID that is currently running through TFS (vNext) build?

。_饼干妹妹 提交于 2019-12-12 04:32:07

问题


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();

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

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?

I am using TFS 2017 on-premise.

Thanks!


回答1:


You can’t get test case id in test method as running test through MTM when run tests during the build (Functional test).

The Workaround is that you can specify the value in runsettings and get the value during test.

More information, you can refer to Supplying Run Time Parameters to Tests




回答2:


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.



来源:https://stackoverflow.com/questions/42843920/how-to-retrieve-a-test-case-id-that-is-currently-running-through-tfs-vnext-bui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!