Visual Studio Unit Test: Huge startup delay in debug Mode - visual-studio

I'm working on a big code project. When I try to run a unit test in debug mode using nunit on Visual Studio 2013 Ultimate, there's a consistent 40 second delay before the test runs. Now, once the test starts running, it runs as fast as I'd expect. And if I run the test in Release mode, there's no delay.
I know it's a local environment problem because other developers report no similar delay when they fire up a test on the project.
I've been unable to determine what's causing this delay. The only visual evidence is that the cursor changes to a spinning cursor. I've disabled everything in Options that looked like it might be demanding. I have NCrunch and Resharper installed, but both are disabled, so neither appears to be at fault.
Any suggestions?

Related

How to run tests while debugging

I've been using ReSharper test runner in Visual Studio for quite a while, and there is one thing about it that I can't figure out.
I used to have some integrational tests in my solution that performed web requests to my local web server. I used to be able to launch my web application in debug mode, then launch a test with Resharper test runner within the same Visual Studio instance (that was currently running a debug session), and the test would run normally. The breakpoints in my application were hit, and I was able to debug the requests sent from the test.
However, when I was trying to do the same thing for a new project, the tests fail to launch. When I run any test, Visual Studio displays a modal window asking Do you want to stop debugging?. Why am I unable to run tests while having an active debugging session anymore? What does the ability to do this depend on? Visual Studio version? Resharper version? Unit testing framework (I'm currently using MSTest)?
I think I've seen this behavior before, it seemed to be driven by the fact that Resharper was feeling the need to always build my project/solution before running tests.
Try changing the Build Policy to Never (at first at least) from the Unit Test Sessions window:

Test execution error in Visual Studio 2015 (worked in 2013)

We are in the process of upgrading from Visual Studio 2013 Update 5 to Visual Studio 2015 Update 1.
Our Solution has many tests and we use NUnit 2.6.4, along with the NUnit Test Adapter for NUnit 2.x.
When running these tests in Visual Studio 2013, they all run perfectly well.
However, when running in Visual Studio 2015 the first 200 odd tests run, then execution stops. I can then select the tests that have not yet run and successfully execute these. I have the latest ReSharper installed in both VS2013 and VS2015 and it happily executes all the tests.
We've been keeping test-coverage details for each release since the dawn of time, and from Visual Studio's test runner it shows me the number of blocks covered. But ReSharper shows us the number of statements covered. Slightly different values, but they'd mess up our charts.
When test execution fails, it creates a Dump file (it also creates some XML files that just seem to show what DLLs I've installed). I can open this and "debug" it, but it simply shows me a line of code that fails, and the call stack shows only [Managed Code], which means I can't identify the actual test that's causing the issue.
The fact that this works perfectly in VS2013 and in ReSharper running in VS2015 suggests that "it's not our fault", but whilst I'd like to think that, it doesn't help me fix this.
Any ideas?
Thanks
Griff
Tracked down the problem. We had one class in our Solution that implements IDispose and one of our Unit tests didn't dispose of that class, it just allowed it to go out of scope.
So because the Disposable object hadn't been disposed, the class' Finalizer hadn't been suppressed. The GC therefore called the Finalizer which in turn attempted to access another object that had also gone out of scope, resulting in an exception that crashed the Test Execution Runner.
Interesting that VS2015 running NUnit 2.x crashes, but the identical setup in VS2013 copes fine.
As an aside, when debugging the DUMP file (see above), I realized that the call stack was irrelevant, I just had to put in some defensive coding in the Finalizer.

VS2013 Resharper always runs all tests

I got this strange problem with VS2013, NUnit and resharper
When I try to run a single test it always runs all tests in the project. It doesn't matter if I select Run or Debug or if I start it from the editor, unit test explorer or unit test session.
Only the test I started show up in the Unit Test session. No results from the other tests is visible but break points are hit in all tests.
The problem seem to start at random after editing a test. Have tried clean rebuilds and restarting Visual Studio but the problem remain.
Restarting the computer helps but only until it starts again after some edit.
Using VS2013 update 5, Resharper 10.01 and Nunit 3.0.1 (also tried 2.6.4)
Is this a Visual Studio, NUnit or Resharper problem?
Only other strange thing I noticed is that CTRL-Q (R# show documentation) does not work within test methods. It always show documentation for the test method not the variable or class the cursor is on.

Visual Studio 2015 RC Test Run hangs

Found a strange issue in VS 2015 - running a single unit test hangs if previous test run were interrupted by Stop Debugging.
Steps are:
Set a breakpoint on the first line of some test method.
Start that test under debugger, wait for breakpoint hit.
Hit Shift+F5 or Debugging/Stop Debugging.
Start that single test again - it hangs on start somewhere in te.processhost.managed.exe native code.
Restarting the VS or just running all tests by hitting Run All helps, but only until the next Shift+F5 hit.
I was able to reproduce it both locally and on clean Azure VS 2015 RC VM, so it looks like a but, not just some machine-specific glitch.
Switching Test / Test Settings / Default Processor Architecture from default X86 to X64 works for me, as it enables old vstest execution engine.
This issue on MS Connect Site.
Are there are any other known workarounds?

How to prevent Visual Studio from killing any process after test execution

I am using Visual Studio 2012 MSTest framework with Silk4NET plug in. Every time when a test case finishes running, the Application Under Test is killed. This is REALLY annoying because this makes inspection harder in that I have to re-run the test and have to manually stop the test code to investigate the issue.
Does anybody know if I can disable this feature in VS where it kills everything after test execution? Thank you!
You need to add a line to the test that sets CloseOnPlaybackCleanup flag to false:
browserWindowInstance.CloseOnPlaybackCleanup = false;
This flag was added in Visual Studio 2010 SP1. Here is an MSDN Blog post.

Resources