How to disable test discovery in visual studio 2017? - unit-testing

I have some solutions with a bunch of projects and we have no unit test project in these solutions. However Visual Studio 2017 is still trying to discover unit tests and slowing down our process.
https://imgur.com/a/89Vt1P6
I looked at the runsettings xml file but there was nothing in there to disable it
https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file
any idea how we turn this unnecessary stuff off for some of our solutions?
Thanks

This was driving me crazy too. One day it just started running test discovery after every build, and switching my output pane to "Test" which is annoying.
How I fixed it in VS 2015 (may be the same for 2017),
disable (uncheck) this setting:
Test menu --> Test Settings --> Keep Test Execution Engine Running

Related

Visual Studio Test Explorer window not refreshing

Multiple times throughout the day, my Test Explorer window in Visual Studio 2017 is locking up. Whilst it doesn't crash VS, when affected I can't run any tests as none of the options are available when right clicking on a test....
I have a mixture of NUnit and SpecFlow+ tests in different projects. Cleaning and rebuilding the solution doesn't work, the test explorer window doesn't change. Attempting to use the 'NUnit test (click to run)' option also does nothing.
The only way to resolve this issue is to restart Visual Studio which is highly frustrating.
Anyone know what the issue could be?
Thanks
I was also facing the same issue, as a workaround I Unloaded my test project and then Reloaded back; then ran the test again. This time it refreshed the Test explorer :)
My VS version: VS Professional 2019 Version 16.9.6.
Note: I had to do this to all my Test projects.
I have had multiple issues with specflow+. In the end I uninstalled specflow+ and went with normal specflow. This solved many issues for me, including this issue. Hopefully it will work for you as well.

visual studio code unit test discovery frequency setting

When I'm updating my existing unit tests, Visual Studio code drops a status bar from the top letting me know that it could not correctly discover unit tests every time I save the file. This is expected since I'm actively typing so everything is not working python.
Have I configured something incorrectly? Is there some way to tell visual studio to chill out on the unit test discovery?
Of course, I can simply hit the "close" button, but this is extremely distracting.
Disable Live Unit Test running on the background.
Under Test->Test Settings-> uncheck 'Keep Test Execution Engine Running'. I am using VS 2017 & VS 2015.

How can I disable code coverage / assembly instrumentation in Visual Studio 2012?

I have a project upgraded from Visual Studio 2010 to 2012 and the .testrunconfig file was included in the upgrade process.
I noticed that it was possible to click "Analyze code coverage" on any of the unit tests that I had run and it would correctly display the result. However, my test run configuration (originally from VS 2010) had code coverage disabled.
After doing a bit of research I learned that the VS 2010 configuration files have been deprecated and replaced by .runsettings files. It would appear that VS 2012 enforces assembly instrumentation by default which has a massive overhead associated with it.
Therefore, I would like to know how I can disable code coverage in VS 2012. Based upon my current findings it does not seem to be a trival task. One recent article I read had me creating an XML file manually and naming it "MYCONFIGURATION.runsettings" and manually manipulating XML attribute values.
Does anyone know how this should be done?
This is what I understand from your post:
You have a Test project with .testsettings file. You have not enabled code coverage in the test settings.
Code coverage instrumentation is not enabled by default in your scenario. Binaries will be instrumented if you do 'analyze code coverage' from VS.
Additional Info:
You can confirm that .coverage file is not generated by running the following command from visual studio developer command prompt:
vstest.console.exe /Settings:<your test settings file> test.dll
A coverage file will only get generated if you have enabled coverage in test settings.
Code coverage is only enabled through the Test Explorer using data driven adapters. The metadata for tests ran through the test explorer is almost completely different than that of tests ran straight from the unit test session window. Have you tried simply running it straight from the code (the MSTest gui bubbles) or from the unit test session window?

How to profile unit tests in Visual Studio 2012?

Is it possible to profile MSTest unit tests in Visual Studio 2012 Ultimate without using any external profiling tools?
This feature was added back in the upcoming Visual Studio 2012 Quarterly Update 1. Right-click the test you want to profile in the Test Explorer and select "Profile Test" from the context menu.
In Visual Studio it was a really powerful feature !
As you, I can not find it in VS2012 (no references in MSDN or in blogs, ...)
Now, the only solution I have found for profiling Unit Test is to Attach the Profiler to a Process called vstest.executionengine.x86.exe (x86 for me but this could be different for 64 bits)
You can do this in the Tab "Performance Explorer" after a right click.
Once the profiler is starting, you can run as many tests as you want. Then stop profiling and you will see all details of this session.
There are 2 caveats with this technique :
for some reasons, the process is missing in the list. Maybe it stops when idle. Start just one test te see it.
You have to Attach the Profiler for every sessions. I don't find yet a way to script it.
Hope this will help you.
In Visual Studio 2015, follow the instructions Cybermaxs gives, but select TE.ProcessHost.Managed. Unfortunately, there appear to be two of them, so you must select the one with higher CPU usage.
With VS 2019/2022 you attach to the testhost process while running your tests. Just run your tests in debug, and stop execution on breakpoint, then you can find that process to attach.

How to write unit test for Visual studio package

I am now working on a visual studio package project, currently all our tests just simulates the way we interact with visual studio with windows open and close, menus selection, button click and so on.I think these tests can be classified as integrated test and they highly depends on the devenv.exe process. For pure unit test, I just want to test one of my business logic and mock other dependencies.Although visual studio SDK contains a test library under the path VisualStudioIntegration\Common\Source\CSharp\UnitTest in SDK folder, I found it a too simple project, too young to be used in my project. When I tried to write unit test from scratch, I got a lot of problems with mocking VSX interfaces. Also there is so little resources about VSX unit test, Can anyone give me some hints or links about this? Any help is appreciated.
In my case, I needed to launch and control Visual Studio from a control program to run some developer studies.
Basically, why not just have your tests run your plugin in the experimental hive on a programmatic instance?
This was a helpful resource for launching an instance of Visual Studio through COM:
http://blogs.msdn.com/b/kirillosenkov/archive/2009/03/03/how-to-start-visual-studio-programmatically.aspx