Question

I have XML spreadsheet files created from Excel that I need to use as the input for my data driven test. I can't use the DataSource attribute on my test method because of inconsistencies parsing the files with an Oledb provider. I was wondering if there is a way to have nested test results like the way the DataSource attribute does it?

I'd prefer for MSTest to show the breakdown of each row that was iterated as opposed to me catching a failed assertion exception and keep a collection of the failures. I of course want the test to run against every row and not quit executing upon the first failed assertion.

I'm not looking for answers that insist on loading the data via the DataSource attribute. Thanks

Was it helpful?

Solution

  1. Use the DeploymentItem on each of your TestMethods to deploy the XML spreadsheet file that each Test needs. It will be deployed in the Assembly's location.

  2. In the TestInitilize method use the path of the Assemby to parse your file to your custom DataSource (maybe a list of objects of your input data).

  3. Put your TestMethod's code catch in a try/catch block. If an exception is thrown report the error using the TestContext.WriteLine method or append it in your custom results file (something like this).

  4. Use a class level counter and at the end of each TestMethod check if the counter equals to your custom datasource lenght. If not, increase it by one and rerun the test.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top