Search code examples
c#multithreadingmstestdata-driven

multi thread - ms test - data driven test


Background

I have written a test suite in "mstest" which has a template XML.

The test populates this template with data from my database and posts it to a web service. When the web service replies with a response, input XML data is compared with the XML data received from the service in its response, and entries are logged in a text file.

Basically this test has one entry point function (it's the only function with the test method attribute) which then drives all the other functions in the test

The problem

The problem is that when the test takes too long. Posting to the web service and getting back a reply takes almost 2 mins for each instance and I have 100 such data instances, so it would take about 200 mins at a minimum to complete.

My Boss told me to look into multi-threading this test thus hopefully reducing time.

One more thing i would like to point out is that I am going through different input xml instances using the DataSource attribute similar to what is mentioned in this article. The difference is that I am using a view from my DB to run the datasource attribute rather than a CSV file.

Any ideas how to multi thread this test and maintain thread safety will be greatly appreciated. Thanks in advance


Solution

  • TPL works for me, just had to ensure each and every variable was local