Xml file not copying to test output directory

后端 未结 4 1698
不知归路
不知归路 2021-02-06 21:19

Visual Studio 2010, x64 machine, using the built-in web server to host a WCF service with a set of unit tests using the built-in test framework.

I have an XML file that

4条回答
  •  清酒与你
    2021-02-06 21:55

    Try annotating your test with the DeploymentItem attribute: http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.deploymentitemattribute(v=VS.100).aspx

    Here's a code snippet from the documentation:

      [TestClass]
        public class UnitTest1
        {
            [TestMethod()]
            [DeploymentItem("testFile1.txt")]
            public void ConstructorTest()
            {
                // Create the file to deploy
                Car.CarInfo();
                string file = "testFile1.txt";
                // Check if the created file exists in the deployment directory
                Assert.IsTrue(File.Exists(file), "deployment failed: " + file +
                    " did not get deployed");
            }
        }
    

提交回复
热议问题