1

I have a Generic Test defined in Visual Studio 2012.

If I hard code all the paths then the test runs perfectly. Obviously I need relative paths for this to work on a build server. However, it fails to deploy my files because it is looking in the wrong place.

Under "Additional files to deploy with this generic test:" my solution relative files appear like so (verbatim):

<Solution Directory>\SubDir\Tester.exe

When the test actually runs, the output shows the following error:

Warning: Test Run deployment issue: Failed to get the file for deployment item '\SubDir\Tester.exe' specified by the test 'generictest1': System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\SubDir\Tester.exe'.

As you can see, It's using Visual Studio's working directory rather than the '<Solution Directory>' it claims.

Any ideas on how to fix this, or what I might be doing wrong?

4

1 回答 1

0

关于这个问题有几个相关的已回答问题: Problem with DeploymentItem attribute C# DeploymentItem failed to copy file for MSTest unit test

但是,在 VS 2012 中,MS 对 MSTest 进行了更改(不幸的是,我找不到他们针对这些更改所做的几篇博客文章的 URL - 他们在他们所做的其他新内容之间有所提及)所以现在当你有一个程序集作为部署项 - 无论是来自测试类、测试方法还是 TestSettings 文件,它都可能仍然被遗漏!

原因似乎是 mstest 从引用的程序集中查找类实例化。如果没有,则不会复制程序集。我们在使用框架的测试中遇到了这个问题,而框架又使用了 NewtonSoft.JSON。我们必须创建一个虚拟测试类和方法来实例化 NewtonSoft.JSON 库中的任何类,以便复制其 DLL。

试一试,祈祷它有效。

于 2013-07-15T11:47:02.573 回答