Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Not Listing DataDriven Tests  #32

@ZcuBa

Description

@ZcuBa

So A test method could look like this:

`
public TestContext TestContext { get; set; }

    [TestMethod]
    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", @"|DataDirectory|\DataFiles\PolynomialParseTests.csv", "PolynomialParseTests#csv", DataAccessMethod.Sequential)]
    public void PolynomialParsing()
    {
        string source = (string)TestContext.DataRow["source"]; // get the value from the 'input polynomial string' column
        string target = (string)TestContext.DataRow["target"]; // get the value from the 'expected' coeffecients column

        Polynomial P = new Polynomial();
        P.Parse(source);

        string[] coeffecients = target.Trim().Split(';');
        List<double> C = coeffecients.Select(c => double.Parse(c, CultureInfo.InvariantCulture)).ToList();

        CollectionAssert.AreEqual(C, P.P);
    }

`

with a datafile like this:

id,source,target,comment
0, "2x^2+x" ,0;1;2,
1, " 2x^2 + 1.0x " ,0;1;2,
2, "2x^2 + 1.0
x + 0" ,0;1;2,
3, "2u^3 + u " ,0;1;0;2

`this actually prduces 4 runs of datadriven tests, for this test method.
this is not shown in the html.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions