title: Catch exception in xunit test
body: <p>Can I catch the exception that appears in the log but not in the test?</p>
  
  <p>I performed the test and it returned the status: OK, but in the log I have:
  Unexpected error publishing create package to Kafka. id = 5ec3eb81aa662c8a7c76e5e8. Exception: System.NullReferenceException: Object reference not set to an instance of an object.</p>
  
  <p>How can I catch this exception in the test? I tried to use Try and catch (Exception) but nothing catches.</p>
  
  <pre><code> [Fact]
      [DisplayTestMethodName]
      public async Task ExceptionTest()
      {
          try
          {
              var testRequest= @"{""Test1"":"1234"};
              var testRequestResp =
                  await fixture.PostAsync(testRequest);
              Assert.Equal("HttpStatusCode: " + System.Net.HttpStatusCode.OK, "HttpStatusCode: " + testRequestResp.StatusCode);
          }
          catch (Exception ex)
          {
              Assert.True(ex == null, "Exception: " + ex.Message);
          }
  </code></pre>
  
  <p>Log
  <a href="https://i.stack.imgur.com/lVNpu.png" rel="nofollow noreferrer">VS log</a></p>