Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read parameter values from a TestCase in Microsoft Test Manager

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

Regards Harsh

like image 899
HarshJain Avatar asked Nov 17 '11 06:11

HarshJain


People also ask

How do you add parameters to test cases MTM?

Add parameters to a test caseCreate a parameter by typing a name preceded by "@" in the actions and expected results of your test steps.

How do you define test parameters?

A test parameter is a variable that can be assigned a value outside the test execution. It enables the testing steps of a test case to be executed multiple times/iterations with variations in the test procedure.


1 Answers

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

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

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

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

like image 112
chaliasos Avatar answered Oct 11 '22 11:10

chaliasos