Visual Studio Test Project - Does not copy folder on deployment

前端 未结 4 1587
失恋的感觉
失恋的感觉 2021-01-08 01:27

Here is the problem:
1. Create a TestProject in your Visual Studio solution.
2. Open the .testrunconfig file and under the \'deployment\' menu item, select the \'Ena

4条回答
  •  终归单人心
    2021-01-08 02:08

    Use the [DeploymentItem] attribute on the test classes that use it. You can specify a directory:

    [TestClass]
    [DeploymentItem("blahblah\\myDirectory", "myDirectory")]
    public class MyTest
    {
    
    }
    

    Note:

    • DeploymentItem is very slow when starting the tests. It seems to copy 2 files per second.
    • You can specify the attribute on a test base class. But it does not always work if you have more than one test project.
    • You can probably specify it on a TestClass that has a method marked with [AssemblyInitialize]. Then you have only to provide it once. Not sure, you have to try.
    • The source directory is relative to the solution location. This is hardly documented.

提交回复
热议问题