Howto resolve .net test hangs on "Starting test execution, please wait..."

dotnet test multiple projects
dotnet test -parallel
dotnet test dll
dotnet test-nunit
xunit runsettings
dotnet test timeout
dotnet test test run in progress
dotnet run hangs

I am trying to execute dotnet test from the command line on our Jenkins build server, but it just hangs on:

Starting test execution, please wait...

It works fine when running this command locally

If I switch to using dotnet xunit it fails with the following:

15:42:57 Locating binaries for framework netcoreapp2.1...
15:42:58 Running .NET Core 2.1 tests for framework netcoreapp2.1...
15:42:58 The specified framework version '2.1' could not be parsed
15:42:58 The specified framework 'Microsoft.NETCore.App', version '2.1' was not found.
15:42:58   - Check application dependencies and target a framework version installed at:
15:42:58       C:\Program Files\dotnet\
15:42:58   - Installing .NET Core prerequisites might help resolve this problem:
15:42:58   - The .NET Core framework and SDK can be installed from:
15:42:58   - The following versions are installed:
15:42:58       2.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
15:42:58       2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
15:42:58       2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
15:42:58       2.1.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
15:42:58       2.1.4 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

As per the error message, we have installed the dotnet core SDK on the server but we seem to be missing something.

My test project looks like:

<Project Sdk="Microsoft.NET.Sdk">    
    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
    <PackageReference Include="Moq" Version="4.10.0" />
    <PackageReference Include="RichardSzalay.MockHttp" Version="5.0.0" />
    <PackageReference Include="xunit" Version="2.3.1" />
    <PackageReference Include="xunit.runner.console" Version="2.4.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

The versioning was a red herring and it turned out to be much simpler problem. My tests were testing Async controller methods, and my non-async tests were doing:

var result = controller.PostAsync(request).Result;

as soon as I changed the tests themselves to use the async/await pattern they worked fine:

var result = await controller.PostAsync(request);

Something that helped me diagnose the issue was using the dotnet test --verbosity d argument. When using this it was outputting some tests that were passing rather than just "Starting test execution, please wait". Interestingly every time I run the command it would execute a different number of tests before appearing to get stuck. This suggested there was perhaps some sort of thread deadlock issue which led me to the solution. I'm still unsure why the command ran fine on my local machine but not our Jenkins slave.

dotnet test keeps hanging · Issue #3443 · dotnet/aspnetcore · GitHub, Tests hang forever. Environment data. dotnet --info output: Dustins-MBP:giraffe dustinmoris$ dotnet --info .NET Core SDK (reflecting  How to resolve job hangs and collect diagnostic information. 03/23/2020; 2 minutes to read; In this article Problem. Execution of a streaming or batch job hangs, but the cluster does not hang. Cause. There are various rare scenarios and corner cases that can cause a streaming or batch job to hang.

Sometimes xUnit tests hang forever because the test runner pipeline can't handle parallel threads.

To check if that's the issue try adding xunit.runner.json file to the tests project root

    <None Update="xunit.runner.json">

And put inside 1 thread config.

  "parallelizeTestCollections": true,
  "maxParallelThreads": -1

Tests hang from dotnet test · Issue #2080 · microsoft/vstest · GitHub, Steps to reproduce Tests run on travis CI via dotnet test now intermittently fail. Failures NET Core SDK. Try to fix test output on Travis CI … The Microsoft .NET Framework Repair Tool detects frequently occurring issues that affect Microsoft .NET Framework setup or updates. The tool tries to resolve those issues by applying known fixes or by repairing corrupted installations of the supported .NET Framework versions. The tool has an easy-to-use, wizard-based user interface (UI).

The solution that worked for me was to add an AssemblyInfo.cs file with the following contents:

using Xunit;

[assembly: CollectionBehavior(DisableTestParallelization = true)]

Once I did this, the tests started running in my CI builds again (in my case, Azure Pipelines).

Test Explorer Hangs Indefinitely, Test Explorer Hangs Indefinitely - Builds Seem to Run in a Loop NET Core 1.x not being available to run the tests… but you can remove this target If we haven't resolved this issue for you, please report a new problem. It applies to all types of .NET processes and to some extent also to processes even though it has some .net specific items. Define the hang/performance issue The first step in troubleshooting a performance issue/hang of any kind, whether it is .NET or native is to find out what we are dealing with and what the expected resolution is.

Updating Microsoft.NET.Test.Sdk from 15.9 to 16.3 helped in csproj file.

Test Driven .NET Development with FitNesse, Understanding what really happens during a test allows you to customise FIT and FitNesse to your particular project needs and troubleshoot tests. Now that we've learnt how displays them to the user. This is why, when tests are hanging and  The dotnet test command is used to execute unit tests in a given solution. The dotnet test command builds the solution and runs a test host application for each test project in the solution. The test host executes tests in the given project using a test framework, for example: MSTest, NUnit, or xUnit, and reports the success or failure of each test.

dotnet test command, NET Core. The bitness of the dotnet.exe that is on the path is what will be used for running tests. For more information, see the following  by Mike Volodarsky, former ASP.NET 2.0/IIS 7 PM. In this guide, I will show you how to troubleshoot an IIS or ASP.NET website hang in production, with the freely available Microsoft tools and techniques I've been using since the development of IIS 7.0. Note: This is the original guide that inspired LeanSentry's automatic hang diagnostics.

Visual Studio 2019 version 16.5 Release Notes, Available for pre-release testing. NET Core Support and More in Visual Studio 2019 version 16.3 - Update Now! X: Multiple startup projects while Live Visual Tree was last opened in a debug session crashes; Fixed issues Fixed a bug preventing some users from installing 16.5; Fix an issue where  wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. The wikiHow Tech Team also followed the article's instructions, and validated that they work. Learn more

How to Solve the Top 7 .NET Application Performance Problems , NET applications and provide tips to troubleshoot and resolve them. But when the IIS web site just hangs and all or most web pages take  VS 2017 Stops Responding / Freezes / Locks up. Closed - Fixed visual studio 2017 ide repos Fixed-in: Visual Studio 2017 Version 15.1 windows 6.3. Josh Clark reported Mar 09, 2017 at 03:14 PM.