f4x
f4x

Reputation: 138

MSTest DeploymentItem doesn't copy files to output dir

nice day!

I have following project structure:

Solution
-My.Project
-My.Project.Test
--Resources
---mytest.file

In my test file following method:

[TestMethod]

[DeploymentItem("My.Project.Test\\Resources\\mytest.file", @"Resources")]

TestMethod()

{

....

string path = "Resources\\mytest.file"; ....

}

In according to http://msdn.microsoft.com/en-us/library/ms182475%28v=vs.100%29.aspx I want use only DeployItemAttribute without "Deployment Items property".

But when I debugged it method, I catch "File not found exception".

What can I do?

PS: also posted this question in http://social.msdn.microsoft.com/Forums/en-US/vststest/thread/474d51ee-7ab9-4311-b7b0-b21266eb01d5

Best regards!

Upvotes: 2

Views: 17072

Answers (3)

Tyler Angell
Tyler Angell

Reputation: 151

Heads up that the path in [DeploymentItem("path")] is case sensitive.

For example: [DeploymentItem("MyTest.file")] is different than [DeploymentItem("mytest.file")] and will cause your deployment item to not be copied over to the TestResults Out folder.

Upvotes: 4

Mark Conway
Mark Conway

Reputation: 492

Yes, marking my "App.config" file as "copy always" fixed it for me.

Upvotes: 0

Elena
Elena

Reputation: 1946

Check the properties of the file to deploy (mytest.file).

"Copy to Output Directory" should be set to "Copy Always" (it is set to "Do not copy" by default).

Upvotes: 10

Related Questions