0

I have built a bunch of tests for my employer using Test Driven Development. I am now trying to use Data Driven Development for these tests. Unfortunately, whenever I try to setup the Data Connection String with an XML file, Visual Studio 2010 keeps giving me the same error.

I don't have a high enough reputation on the site to post an image. The error says, "Error trying to sample data from , please make sure the file is valid.

I have tried a simple XML files instead of my more complex one. I have set the "Copy to Output Directory" property for the file to "Copy Always". I have tried to manually fill in the data source attribute instead of using the wizard. I have gone to test -> edit local test settings and enabled deployment. I am out of ideas can anyone help. Perhaps it is the way I am making the xml files? I have been building them in notepad+ and saving with .xml.

Thank you!

1 Answer 1

2

This sound to me like your tests cannot find the physical locatin of the XML file.

Have a look at MSDN article How to: Create a Data-Driven Unit Test for walkthrough at how to implement data driven tests, including example ConnectionString.

Also make sure that under dialog Test -> Edit test settings -> Local (local.testsettings) the CheckBox Deployment -> Enable deployment is activated. This forces the deployment of your files rather than just relying on the attributes. For more explanation, see this article MSTest Aggravation and a Solution (For Me Anyway).

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for the quick response. Unfortunately, I have tried both of those websites already and followed all of their steps. My problem is happening in the data source wizard after going to TestView then right click on the test and selecting properties. Any other suggestions?
@JamWils: Hm, strange. I got my tests finally working with just the information from the MSDN link. But I do remember that I had troubles with XML, too. As now that I think about it, I remember that I did not manage to use any data that was deeper nested than DIRECTLY under the root node. As I felt that this would not lead me anywhere, I eventually switched to CSV files. Possibly you have the same troubles here. You could try the following: Create a simple test XML without any node nesting and see, if your data then displays.
Wow! So I tried your idea for a simple XML file to no avail. Then I noticed when I opened the xml in Internet Explorer that nothing was appearing on the screen. It turns out it didn't like encoding="utf-16". I was using notepad++ and found that utf-8 works. It is now importing into Visual Studio. Thanks for helping me out.
@JamWils: I am glad that you finally got it working! If I could help, how about a little upvote...? ;-)
Unfortunately, I do not have a high enough reputation to upvote yet. When I do I will come back and upvote it. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.