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!
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