Visual-studio – MSTest copy file to test run folder


I've got a test which requires an XML file to be read in and then parsed. How can I have this file copied into the test run folder each time?

The XML file is set to "Copy if newer" and a compile mode of "none" (since it's not really a compile-able thing)

Best Solution

use a DeploymentItem attribute

using System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CarMaker;

namespace DeploymentTest
    public class UnitTest1
        public void ConstructorTest()
            string file = "testFile1.xml";
            Assert.IsTrue(File.Exists(file), "deployment failed: " + file +
                " did not get deployed");