开发者

MSTEST folder deployment question

Is there a way to preserve folder structure with MSTEST deployment?

I have a situation with some existing code where I have .config files in a subfolder (called "Configuration"). I can specify this folder using MSTEST deployment but, in it's infinite wisdom, MSTEST just copies the files from this folder to the run folder (TestResult\\Out), i.e. it does not create a subfolder called Configuratio开发者_C百科n. This royally screws up the code and it fails. I don't really want to have to start using complicated pre-test scripts to create folders etc.

Any ideas gratefully received.

Matt


I think I had the same problem...

My tests used a folder called xsd and I wanted to deploy the folder to the test \OUT directory. When I did this, the files inside the xsd folder were copied to the test \OUT directory, but I wanted the folder xsd into the test \OUT directory...

To solve this I read this. (Wayback machine has an archive of this page here)


If you're using the DeploymentItem attribute, it takes a second argument for the name of the directory to copy the files into. If you use the same name as your folder it preserves everything.

To use your test case you'd do:

[DeploymentItem("Configuration", "Configuration")]
class TestClass
....

and it would work.


Yes, you can. read the article Do MSTest deployment items only work when present in the project test settings file?

It explains how to map deployment items.


In Visual Studio 2012 the output directory is the working directory which means that the DeploymentItem attribute isn't needed for the general case (where you don't have specific per-test or per-class deployment items). You can simply click Project | Show All Files and include the subfolder and files in Visual Studio with the 'Copy Always' or 'Copy if newer' attribute to your project and the files will be copied to your output directory with hierarchy intact. The same applies when running vstest.console.exe from the command line.

See here for more information about Deployment Items in Visual Studio 2012.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜