Adibe7
Adibe7

Reputation: 3539

Open an xml file that is included in the project

I added an XML file to a directory that i have in the test project.

How can i access it from the test code?

Upvotes: 0

Views: 74

Answers (1)

Andy May
Andy May

Reputation: 4070

You didn't mention what language or IDE you're using, but here is what I've done with C# in Visual Studio:

  1. Add your XML files to the Unit Test project (create a new folder for your test files).
  2. Go to Test -> Edit Test Settings
  3. Click on Deployment
  4. Check the box "Enable Deployment" and add the directory you created in step one.
  5. In the unit test:

    string testxml = File.ReadAllText("test.xml")

Upvotes: 1

Related Questions