如何从Microsoft Test Manager中的TestCase读取参数值 [英] How to read parameter values from a TestCase in Microsoft Test Manager

查看:410
本文介绍了如何从Microsoft Test Manager中的TestCase读取参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用microsoft测试经理使用c#以编程方式执行测试程序。
为此,我想读取存储在Microsoft Test Manager中的参数值。
请建议我如何做
例如: - 读取内部参数的值MY Value
我试图输入图像,但它不工作...

I am trying to execute the testcases programatically using the microsoft test manager using c#. For that I want to read the parameter values stored in Microsoft Test Manager. Please suggest me how to do that Eg:- Read the value of internal paramter "MY Value" I tried to enter the image but its not working ...

尊重
Harsh

Regards Harsh

推荐答案

我想你要读取参数您的自动化测试实现的测试用例的数据源。

I suppose you want to read the parameters from the datasource of the Test Case that your automated test implements.

您必须将测试与TFS上的测试用例的ID相关联。

You have to associate your test with the Test Case's Id on TFS.

尝试以下代码。 / p>

Try the following code.

[TestClass]
public class TestClass
{
    public TestContext TestContext { get; set; }
    public DataRow DataRow { get; set; }

    [TestMethod]
    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase", 
        "http://localhost:8080/tfs/[CollectionName];[ProjectName]", "[TestCaseId]", DataAccessMethod.Sequential)]
    public void TestMethod()
    {
        string column1 = TestContext.DataRow[0].ToString(); // read parameter by column index
        string column2 = TestContext.DataRow["Column2"].ToString(); //read parameter by column name
    }
}

您的TestMethod将对测试用例的数据源的每一行(迭代)运行一次。

Have in mind that your TestMethod will run one time for each row (iteration) of the Test Case's datasource.

这篇关于如何从Microsoft Test Manager中的TestCase读取参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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