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?
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.
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.
Related
I am trying to run Nunit Test using Visual Studio test Runner from XAML build in TFS,but i am getting error saying
TF900547: The directory containing the assemblies for the Visual Studio Test Runner is not valid ''.
Based on your history, I assume you are using VSTS, you can refer to these steps to run Nunit test:
Create a unit test project via VS
Install NUnit and NUnit3TestAdapter packages
Add solution to source control (if the package files not added to the source control, you can refer to the steps below)
Open Source Control Explorer in VS
Add a new folder (e.g. Tools) and add Nuget.exe to the source control
Add bat file to your test project (For example: Tools\nuget35.exe restore NUTest2\NUTest2.sln)
Open XAML build definition and map Tools source folder to agent
Select Process section
Choose TfvcTemplate.12.xaml build template
In the Advance section of Build, specify Pre-build script path with previous bat file.
I am having difficulty building an ordered test in Visual Studio 2015 Enterprise (Update 1) and having the unit tests within the ordered test be able to reference my .runsettings.
Specifically, I need to access the TestRunParameters defined in the .runsettings file.
In any of my test methods, if I access the Properties of the TestContext, the properties I defined in the .runsettings are not found.
Surely I'm not the first to do this. Any help would be appreciated.
I think I understand the bug in Visual Studio. Whenever you select a runsettings file in the VS->Test->Test Settings submenu, they do NOT take effect until I at least do a Rebuild of my Test project (or a Clean solution / Build solution). Simply building does NOT make VS apply the proper runsettings file. There were certain situations where it wasn't applying any runsettings file, but since I started doing a Rebuild Project every time I select a different runsettings file, I've never discovered the TestContext not having my Proerties.
My application has several unit tests projects. All other projects and the unit tests projects get built to a common output directory. With an msbuild task I'm collecting all the unit tests assemblies and run vstest.console.exe to test these assemblies.
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\..\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "Assembly1.UnitTest.dll" "Assembly2.UnitTest.dll" /Platform:x64 /Framework:Framework40 /InIsolation /Logger:trx
This results in an exception: System.IO.FileNotFoundException: Could not load file or assembly 'someassembly.dll' or one of its dependencies. The specified module could not be found.
When I execute vstest.console.exe for a single unit tests assembly the above exception doesn't occur. Further investigation learned me that when testing multiple assemblies at once the vstest.console is copying the test assemblies and depended assemblies to an "out" directory in the "testresults" directory. However not all needed assemblies are referenced by a project but manually copied to the common output directory. Those assemblies are missing in the "out" directory in "testresults" and causing the System.IO.FileNotFoundException.
With MSTest I could use a config file an point to the common output directory by adding a DeploymentItem. For vstest.console this doesn't work anymore.
What can I do to get around this behavior? I don't want to work with an "out" directory. Running my unit tests from the common output directory is just fine.
PS. I have the same issue on TFS 2013 with build definitions. My build definitions are collecting *.unittest.dlls and executing these with the Test Runner.
The solution is using a .runsettings file. In the runsettings file it is possible to specify "DeploymentEnabled". By default this is true. Changing it to false doesn't copy all the assemblies to the out directory of the TestResults directory. More information on the runsettings file: http://msdn.microsoft.com/en-us/library/jj635153.aspx.
Example:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!--Info: http://msdn.microsoft.com/en-us/library/jj635153.aspx -->
<MSTest>
<IgnoreTestImpact>True</IgnoreTestImpact>
<MapInconclusiveToFailed>True</MapInconclusiveToFailed>
<CaptureTraceOutput>False</CaptureTraceOutput>
<DeleteDeploymentDirectoryAfterTestRunIsComplete>True</DeleteDeploymentDirectoryAfterTestRunIsComplete>
<DeploymentEnabled>False</DeploymentEnabled>
</MSTest>
</RunSettings>
Based on this msdn article http://msdn.microsoft.com/en-us/library/jj635153.aspx, in Visual Studio 2012 you need to use an xml file named .runsettings to configure your deployment,code coverage, framework settings etc.
On first glance this looks great as you can hook in adapter settings from any test adapter, e.g. NUnit,MSTest,MBUnit etc. However in my installation of Visual Studio 2012 Premium there are no xsd schemas for creating this file, but there are of course the old schemas for the VS2010 .testsettings file. (xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" aka %programfiles%\Microsoft Visual Studio 11.0\Xml\Schemas\vstst.xsd)
Has anyone found anything other than the sample on the link above to go for creating the run settings file?
Also have you found how to reference the legacy VS2010 .testsettings file from the .runsettings file as there are no specifics on whether it should be relative or absolute in the "SettingsFile" node?
We do not have a public xsd for the .runsettings file as yet.
The way to refer your .testsettings file from your .runsettings is shown below. You can use absolute and relative paths to this file.
<RunSettings>
<MSTest>
<SettingsFile>my.testsettings</SettingsFile>
<ForcedLegacyMode>true</ForcedLegacyMode>
</MSTest>
</RunSettings>
I am running a build using TFS 2008 to build a Visual Studio 2010 solution. The build is set to run unit tests, and when it does, it creates a folder such as this to hold the test results:
D:\Temp\MyApp\MyApp.Dev\TestResults\MyAccount_MyBuildServerName 2010-07-29 18_07_00_Any CPU_Release\Out\
Is there a built-in property I can use in the TFSBuild.proj file to get the path above? I would like to reference something like "$(TestResultsOutFolderPath)" in my build file, but I don't know if such a property exists. So far the only properties I have found only get me to the "TestResults" level and do not add the dynamic folder that contains the timestamp info which I need. Thank you.
I guess there is no built-in property for that. But, you can create your own property in TFSBuild.proj under the PropertyGroup element like
<PropertyGroup>
<TestResultsOutFolderPath>...</TestResultsOutFolderPath>
</PropertyGroup>
you can create the full path by combining the built-in TFS properties
some are listed at TFS Properties