Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Test Project - Does not copy folder on deployment

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 'Enable Deployment' checkbox.
3. Now click on 'Add Directory...' button and add a folder which has some files in it.
4. Run the test project (use a dummy test).

Ok, now go check the TestResults folder: You will see that all the files got directly copied (to the top level)- the folder itself is not copied (with the files under them). This messes up my paths during testing. Can anybody tell how to get the folder copied instead of just the files underneath ?

Thanks.

like image 434
DeeStackOverflow Avatar asked Apr 08 '09 16:04

DeeStackOverflow


2 Answers

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.
like image 51
Stefan Steinegger Avatar answered Nov 19 '22 19:11

Stefan Steinegger


Open the .testsettings file in notepad. Now, you should see that for every folder to copy

<DeploymentItem filename="FolderName\" />

Change this to

<DeploymentItem filename="FolderName\" outputDirectory="FolderName\" /> 
like image 30
Jaikishan Jalan Avatar answered Nov 19 '22 19:11

Jaikishan Jalan