Using XML File as Data Source for Visual Studio Data Driven Testing

Using XML File as Data Source for Visual Studio Data Driven Testing

Scenario :
  Using XML file as data source for Data driven testing in Visual studio 2010 Ultimate
Error Observed: The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
Error details: Object reference not set to an instance of an object.

Resolution:
Please use following attributes on the test methods:
[TestMethod]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML","|DataDirectory|\\TestDataSource.xml","TestData"DataAccessMethod.Sequential)]
public void DemoTest()
{

}

Make sure to add the XML file as Deployment Item i.e.
1) Add this attribute to the test method 
[DeploymentItem(@"\\<Path>\TestDataSource.xml")]
Or 2) Go to test setting and add the XML file as deployment item Or 3) Right click on the XML file - go to properties of the file and set copy to output directory = copy always
Leave a Comment
  • Please add 6 and 7 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Richard Mueller edited Revision 1. Comment: Modified title casing, added tags, removed tag "MS"

  • Nevin Janzen edited Original. Comment: Tags Edit

Page 1 of 1 (2 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Nevin Janzen edited Original. Comment: Tags Edit

  • Richard Mueller edited Revision 1. Comment: Modified title casing, added tags, removed tag "MS"

Page 1 of 1 (2 items)