Reputation: 721
"Run All" from "Test Explorer" does not complete (VS2017 Enterprise) anymore. It stalls with Passed (411), Not Run (309). The counts vary a little, usually roughly half and half.
The output window (Visual Studio | Output tab | Show output from: Tests) contains the following error message:
"The active test run was aborted. Reason: Unhandled Exception: System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain."
The tests continue to run fine in ReSharper (720 of 720 pass). R# is where I usually run my tests. I jump over to Microsoft's "Test Explorer" when I am trying to Analyze Code Coverage (though the tests stall with or without code coverage). It (Analyze Code Coverage) worked as recently as 5/15/2018 (and at least a half dozen to a dozen times before that).
Upvotes: 18
Views: 44225
Reputation: 2621
Ensure you have installed test runners on Visual Studio if using other test frameworks. I migrated all of my packages to Central Package Management and forgot to install xunit.runner.visualstudio so Visual Studio could not run my tests.
Upvotes: 0
Reputation: 195
I had this same problem only to realize that VS, when creating the file, added the modifier internal to the class. Changing it to public fixed it.
Upvotes: 0
Reputation: 5500
same issue here managed to track it down eventually to accidentally having 2 methods tagged as [AssemblyCleanup]
resorted the tried and tested commment everything out and readd a test at a time until it stopped running at which point i knew the issue was the cleanup and at that point was just case of tracking down why it was failing with no errors
more generically if your test are not running check all the none test code Initialise, cleanup, etc if its failing to run then the error is most likely in one of these
Upvotes: 0
Reputation: 4803
This is a long shot but I had my method marked as private which caused it to abort
[TestMethod]
private async Task ComputeDailyMetricsTest()
versus
[TestMethod]
public async Task ComputeDailyMetricsTest()
Upvotes: 1
Reputation: 3212
My test was declared as
public async void DoSomething(...)
To fix it, I changed it to:
public async Task DoSomething(...)
Upvotes: 6
Reputation: 301
In my case, I had an Xunit test class but I was missing the [Fact]
attribute and I kept trying to debug the test by clicking Ctrl R + T.
Just make sure you are not missing the [Fact] attribute like so:
[Fact]
public void My_Test_Method() { ... }
Upvotes: 0
Reputation: 2099
An infinite recursion was causing this problem for me.
The stack overflow exception does not get reported as a test failure.(Probably because there's no stack frame left to report it).
Hope this helps someone get unstuck quicker.
Upvotes: 0
Reputation: 401
Check Output window after setting output window drop down to tests.
My issue was that one of the test was doing an infinite loop.
Upvotes: 1
Reputation: 1293
Check the tests output pane for more details - open the output window and select "Tests" option from the "Show output from" combo box.
In my case, my tests project was targeting a version of .NET core I didn't have installed. I just had to change the project target framework to the correct version and it solved the problem.
Upvotes: 20
Reputation: 721
The Microsoft test runner was being tripped up by a single unit test class that happened to have Task.Run() calls such as the following:
var task = Task.Run(async () =>
{
<various code>
});
These tests were missing calls to task.Wait() to wait for each task to finish before exiting the test.
(This appears to trip up the Microsoft test runner but not the ReSharper test runner. Specifically, the Microsoft Test Runner aborts the sln test run and skips 300+ tests. ReSharper was able to run all tests without incident.)
Aside: The reason for the varied behavior on Windows 7 versus Windows 10 is because the test class was for a Windows 10 sensitive 3rd party control/library.
Upvotes: 7