问题描述
我的所有单元测试项目都在我的解决方案文件夹下的一个文件夹中,并且希望将 TestResults 文件夹与测试项目位于同一文件夹中,而不是在解决方案目录中.
I have all my Unit Test project in a folder under my Solution Folder and would like to have the TestResults folder in the same folder as the Test projects instead in the solution directory.
我发现这可以通过测试设置文件来完成:如何指定位置VS 2010 中的单元测试结果?
I have found that this could be done via the test seeting file:How to specify the location for the unit test results in VS 2010?
但我也读到,在 VS2012 中,您不应再使用测试设置文件.实际上VS2012并没有创建一个.
but I also read, that with VS2012 you should no longer use tests settings files. Actually VS2012 does not create one.
还有别的方法吗?
推荐答案
要为TestSettings"文件夹指定不同的位置,请将 .runsettings
添加到您的解决方案中,如 Visual Studio 文档中所述:http://msdn.microsoft.com/en-us/library/vstudio/jj635153.aspx
To specify a different location for the "TestSettings" folder, add a .runsettings
to your solution as explained in the Visual Studio documentation: http://msdn.microsoft.com/en-us/library/vstudio/jj635153.aspx
我的 .runsettings
文件如下所示:
My .runsettings
file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<ResultsDirectory>.\Visual Studio Test Results</ResultsDirectory>
</RunConfiguration>
</RunSettings>
然而,据我所知,ResultsDirectory 的位置不是相对于解决方案文件夹(就像文档中的示例文件所建议的那样),而是相对于 .runsettings
的位置文件本身.另请注意,此处未扩展诸如 $(SolutionDir)
之类的 Visual Studio 宏.总而言之,.runsettings
文件与特定项目或解决方案无关.
As far as I could tell, however, the ResultsDirectory location is not relative to the solution folder (like the example file from the doc suggests), but rather relative to the location of the .runsettings
file itself. Also note that Visual Studio macros like $(SolutionDir)
are not expanded here.All in all, .runsettings
files are not related to a particular project or solution.
他们推荐在较新版本的 Visual Studio 中使用 .runsettings
文件而不是 .testsettings
的原因也可以在文档中找到:http://msdn.microsoft.com/en-us/library/vstudio/ee256991.aspx
The reason why they recommend using .runsettings
files instead of .testsettings
in newer version of Visual Studio is also found in the documentation: http://msdn.microsoft.com/en-us/library/vstudio/ee256991.aspx
如果您使用 .testsettings 文件,MSTest 测试框架将是用于运行您的测试.这运行得更慢,不允许你从第三方测试框架运行测试.
这篇关于VS2012 单元测试:如何更改 TestResults 文件夹的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!