title: Why does this xunit test deadlock (on a single cpu VM)?
body: <p>Running the following test on a single CPU VM (Ubuntu 18.4)</p>
  
  <pre class="lang-cs prettyprint-override"><code>using System;
  using System.Threading;
  using System.Threading.Tasks;
  using Xunit;
  
  public class AsyncStuffTest
  {
      [Fact]
      public void AsyncTest()
      {
          SomethingAsync().Wait();
      }
  
      private static async Task SomethingAsync()
      {
          Console.WriteLine("before async loop...");
          await Task.Factory.StartNew(() =&gt; {
                                          for (int i = 0; i &lt; 10; i++)
                                          {
                                              Console.WriteLine("in async loop...");
                                              Thread.Sleep(500);     
                                          }
                                      });
          Console.WriteLine("after async loop...");
      }
  }
  </code></pre>
  
  <p>results in this:</p>
  
  <pre><code>Build started, please wait...
  Build completed.
  
  Test run for /home/agent/fancypants/bin/Debug/netcoreapp2.1/fancypants.dll(.NETCoreApp,Version=v2.1)
  Microsoft (R) Test Execution Command Line Tool Version 15.7.0
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  Starting test execution, please wait...
  before async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  </code></pre>
  
  <p>The process seems to deadlock and never proceeds to the expected output <code>after async loop...</code></p>
  
  <p>Running on my dev machine everything works fine.</p>
  
  <p>Note: I know about the possibility of async testing in xunit. This is more or less a question of interest. Especially since this problem only affects xunit, a console application is terminating fine:</p>
  
  <pre><code>~/fancypants2$ dotnet run
  before async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  in async loop...
  after async loop...
  ~/fancypants2$
  </code></pre>
  
  <p>Update:
  Read about some recent fixes related to async in xunit, so I tried this with 2.4.0-beta.2.build4010, but there is no change.</p>