locked
MS UNIT Test - Data Driven RRS feed

  • Question

  • Hi Experts,

    I have the following situation.

    I have a MS Unit Test written in c#.

    This takes .csv file as DataSource.

    I need to pass all the data into single XML file (which I am constructing in my test code).

    But, the test is executing for total number of rows in the data file which I don't want.

    I need to execute one iteration where I can pass all my data into required parameters.

    Is there way to control the test execution flow? or any alternative way to do this?

    Thanks in advance.


    ShaSIn

    Tuesday, September 17, 2013 3:44 PM

Answers

  • Hello,

    I need to execute one iteration where I can pass all my data into required parameters.

    I am not sure about your purpose. I assume that the data in .csv file is like:

    Parameter1,Parameter2,Parameter3..

    11,22,33

    33,22,11

    In this case, the unit test will execute with two iterations: (11,22,33),(33,22,11)

    Now do you want unit test to run just once but (11,22,33),(33,22,11) all data will be executed? I am afraid that it is not possible in data driven unit test. One data row is considered as a test iteration.

    A possible workaround I can think out may be  that you don’t use data driven unit test, instead read data from the XML file directly programmatically and then use them in required parameters instead of reading data through TestContext.Row in data driven unit test. Maybe you can try it.

    Best regards,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Amanda Zhu Tuesday, September 24, 2013 1:24 AM
    Wednesday, September 18, 2013 6:45 AM