How can I stop unit tests from using testresult folders - c#

I and a collegue of mine are running unit tests for the same project (we are getting the project files via TFS so the files themselves are the same for both of us). Also our installation of visual studio is essentially the same version (with him having set something different than me as standard for theme and keyboard. But that aside we even have the same addons installed).
When I run the unit tests they are run in the debug folder of the unit test project. If he runs them they are run in the testresults folder. We already checked the build configurations and they are the same for both of us (with deploy unchecked for both).
So my question here is how can we get his visual studio to stop running unit tests in the testresults folder and instead run them in his debug folder?
(And on that also it would be interesting why essentially identical installations of visual studio show such a different behaviour)
As an addon to this: For specific reasons the unit tests NEED to be run in the debug folder as it causes troubles if not

Related

Unit Tests in Visual Studio 2015 don't run

Neither the integrated test environment nor Resharper won't run any unit tests.
When starting Visual Studio the Test Output Pane shows 10+ lines stating:
An exception was thrown while initializing part "Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider".
This is what I've tried so far:
Clear folder %LocalAppData%\Microsoft\VisualStudio\14.0\ComponentModelCache
Create a simple test project with one class library, one class and one test library containing one unit test for that class
Uninstallation and new installation of Visual Studio 2015
All actions didn't fix the problem. Even the simple test won't run.
Running tests from command line using MSTest does work.
Ensure that your anti-virus programs are not quarantining Visual Studio components.
I had this problem when our corporate IT department changed our Sophos Protection Quarantine policy. VS2015 Unit testing stopped working for everyone, with a similar error.

Visual Studio 2013 - Test Explorer doesn't show native unit tests

I've got a really annoying problem with Visual Studio 2013 Professional - I've got two Unit Tests projects - one of them written in C#, and another written in C++. Both of them are standard Visual Studio Unit Tests projects. When I build both of them and turn on Test Explorer window, only C# test methods appears.
Test Explorer doesn't see any of native C++ test method.
First - I tried to rebuild specific project - didn't work. Then I tried to clean 'n rebuild entire solution - also didn't work.
Do you have any ideas how to solve that problem?
UPDATE (SOLUTION) - 03/03/2016
The problem was caused by C++\CLI project in Unit Tests references.
When I remove that project's reference and rebuild unit tests project, everything works fine and Test Explorer detects all of test methods.
Conclusion - something creepy happens when you are trying to test C++\CLI project in native Unit Tests using Visual Studio 2013 default unit tests template project, which is pretty amazing, because it should works - in normal C++ console application works completely fine.

How to stop visual studio from creating tests database after and on 3001st test

I ran into a strange thing today, I was writing tests in C# in Visual Studio and it just started creating a test database in the TestResults folder after hitting my 3001st test. It saves test names, runner information and so on.
Database Structure
Is there a way to disable Visual Studio from creating a test database in the TestResults folder? Because that thing is heavy...

No xunit tests discovered by vstest.console.exe

I'm putting together a new stack of unit tests to be run together as a CI job. I'm using vstest.console.exe instead of mstest.exe mainly for its ability to run tests from several frameworks, but right now the focus is a few xUnit dlls. The jobs are run as part of a Jenkins pipeline.
I have tested everything successfully on a couple of dev boxes, but annoyingly test discovery is not working on any of the CI build boxes so far. This is after the addition of the 0.99.8 xUnit test adapter vsix (also tested with 0.99.7). The xUnit dlls are being built against 4.5 with the 2.0.0.2378 beta nuget version of xUnit.
I have reproduced the symptoms with the simplest possible dll, with a single public test method, working fine on my own box, not working on any build boxes. The deployment enviroment is pretty straight forward, with a VS2012 install and the xUnit test adapter, on Windows 2012.
I have enabled the TpTrace logging via the vstest exe config files and everything looks fine. I guess I'm looking for a way to troubleshoot the issue further (maybe tracing for the xUnit discovery process) or a workaround the problem. I'd prefer to retain the use of vstest console for the simplicity of running several frameworks.
I have written up this issue via the xUnit codeplex site as well.
I've checked out this SO post but none of the suggested solutions make sense here.
It takes me quite some time to find the solution of how to use vstest.console.exe and xunit for VS2013, so I think it worth the time to explain here how I did for everyone...
The first step is to follow what is explained here to install the pre-release xunit.runner.visualstudio nuget package in the xunit projects that need it to be able to run the xunit test from Visual Studio.
Then, when you run your vstest.console.exe command, you MUST use the parameter /TestAdapterPath.
Your command line should look like something (the path toward the xunit adapter is here relative so, you could put it in absolute or adapt depending on the active directory):
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" c:\path\to\your\assembly.to.test.dll /TestAdapterPath:".\packages\xunit.runner.visualstudio.0.99.9-build1021\build\_common\"
edit: Because the adapter dlls are copied to the output folder, we could simplify the command line giving the path "." to the /TestAdapterPath option:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" c:\path\to\your\assembly.to.test.dll /TestAdapterPath:"."
For information, it works also with NUnit, nuget package NUnitTestAdapter and the command:
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" c:\path\to\your\assembly.to.test.dll /TestAdapterPath:"."
OK so problem solved, but after some frustrating troubleshooting that I will cover in case its useful for someone. The problem was that xunit.execution.dll was not available in the same folder as the dlls containing tests. This is required for xunit discovery. I only got here by:
Setting HKCU\Software\Outercurve Foundation\xUnit.net\Visual Studio Test Plugin\MessageDisplay = Diagnostic (this should be possible via the runsettings file but is not being picked up, and not possible via the VS tools options xunit page because its failing to open)
vstest now spits out 'Skipping xunitTests.dll (no reference to xUnit.net)'
This message actually means that xunit.dll and xunit.execution.dll weren't found in the folder
Problem solved by making sure that dll gets copied into that folder on the build boxes.

why my test project doesn't appear on test explorer

I am using VS2012 (v110)
I create a simple dll application with only 1 function and a test project to test the dll function. I set up both projects to be debug builds for win32 and tried Clean and Rebuild both projects but I don't see any test to be run on the test Explorer windows.
I also reference Dll project in the test project already.
Why isn't there anything shown in Test Explorer windows?
Actually MSTest doesn't work with simple class library projects.
You will have to create a unit test project and place your tests there.
If you use other testing frameworks like NUnit, then you can use plain class library. You can then use NUnit to run the tests outside VS, or use tools like ReSharper to run those tests inside VS
It seems you have used some test frameworks other that MSTest. If you want to use Test Explorer for some other frameworks you should install its runner too. for instance NUnit needs to install its test adapter as and extension in VS.NET
see here for more.
You should be able to modify an existing class library project to get mstest to recognize it as a test project by modifying the ProjectTypeGuids in the .csproj file as detailed in this answer How to get VS2010 to recognize my mstests generated by SpecFlow? (Look for the answer that lists the specific guids and not the currently accepted answer which says to just create a new project.)
Have had a simular problem. Solved it. I have been adding tests project to my VS 2012 solution and tests were not appearing in Test Explorer. Problem was that test project was located in IIS inetpub\wwwroot folder which didn't have windows user rights to modify it. Adding solution folder Windows user rights to modify it solved issue. Tests are now visible in test explorer and able to be debugged. I assume that vstest.discoveryengine.exe process with is run by windows user was not having access to test project files

Categories