VS2012 Unit Tests: How to change the location of the TestResults folder

北城以北 提交于 2019-12-23 09:03:50

问题


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.

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?

but I also read, that with VS2012 you should no longer use tests settings files. Actually VS2012 does not create one.

Is there another way?


回答1:


You can create a small RunSettings file which looks like

  <RunSettings>
     <RunConfiguration>
        <ResultsDirectory>e:\myResultsFolder</ResultsDirectory>
     </RunConfiguration>
  </RunSettings>

Select this setting file via top level menu Test->TestSettings->"Select Test Settings" before running your tests.

You can find more detail on http://msdn.microsoft.com/en-us/library/jj635153.aspx.




回答2:


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

My .runsettings file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <RunConfiguration>
    <ResultsDirectory>.\Visual Studio Test Results</ResultsDirectory>
  </RunConfiguration>
</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.

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

If you use a .testsettings file, the MSTest test framework will be used to run your tests. This runs more slowly and does not allow you to run tests from third-party test frameworks.



来源:https://stackoverflow.com/questions/14754354/vs2012-unit-tests-how-to-change-the-location-of-the-testresults-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!