title: xUnit Async Test Not Working Properly
body: <p>We have been using xUnit Framework in our project as test framework since the begining. Currently there are 2200+ unit tests in project and everything seems fine.</p>
  
  <p>But yesterday i decided to run unit tests at CI builds and nightly builds. Fighting with team build controller to run xunit tests for 1-2 hours i succeed to run tests. But there was a problem, there 22 warning abouts tests like below,
  - Xunit.Sdk.EqualException: Assert.Equal() Failure
  or
  - System.ArgumentNullException: Value cannot be null.</p>
  
  <p>After some more research i realized these tests have to be failed but seems passed because all of these tests are marked with "async" keyword.</p>
  
  <p>Actually there shouldn't be any error, because xUnit supports async tests regarding these posts
  <a href="http://bradwilson.typepad.com/blog/2012/01/xunit19.html" rel="noreferrer">http://bradwilson.typepad.com/blog/2012/01/xunit19.html</a>
  <a href="http://sravi-kiran.blogspot.com.tr/2012/11/UnitTestingAsynchronousMethodsUsingMSTestAndXUnit.html" rel="noreferrer">http://sravi-kiran.blogspot.com.tr/2012/11/UnitTestingAsynchronousMethodsUsingMSTestAndXUnit.html</a>
  Howerver reality is slighter difference for me. Yes xUnit runs without any problem but doesn't test properly.</p>
  
  <p>Here are two little methods.</p>
  
  <pre><code>public async Task&lt;string&gt; AsyncTestMethod() {
      throw new Exception("Test");
  }
  public string NormalTestMethod() {
      throw new Exception("Test");
  }
  </code></pre>
  
  <p>As you can see only difference, the first method defined as "async" 
  And here are two tests for these methods.</p>
  
  <pre><code>  [Fact]
      public async void XunitTestMethod_Async() {
          Program p = new Program();
          string result = await p.AsyncTestMethod();
          Assert.Equal("Ok", result);
      }
          [Fact]
      public  void XunitTestMethod_Normal() {
          Program p = new Program();
          string result =  p.NormalTestMethod();
          Assert.Equal("Ok", result);
      }
  </code></pre>
  
  <p>Both of the original methods throws exception,so i think both of the tests should fail but the result is different. You can see the results:
  <img src="https://i.stack.imgur.com/7KXLZ.png" alt="Test results"></p>
  
  <p>XunitTestMethod_Async test pass but XunitTestMethod_Normal fails.
  Throwing an exception is not the case, you can change the method content whatever you want AsyncTestMethod always passes.</p>
  
  <p>Here is the example solution: <a href="https://github.com/bahadirarslan/AsyncTestWithxUnit" rel="noreferrer">https://github.com/bahadirarslan/AsyncTestWithxUnit</a></p>
  
  <p>I might misunderstood or think wrong but now this behaviour causes lots of pain for me </p>
  
  <p>Hope you can enlight me.</p>
  
  <p>PS: I created an issue at xUnit github page, but i couldn't be sure that is this caused from me or xUnit. So i decided to ask here too.
  Issue: <a href="https://github.com/xunit/xunit/issues/96" rel="noreferrer">https://github.com/xunit/xunit/issues/96</a></p>