C# 如何调试异步XUnits测试?

C# 如何调试异步XUnits测试?,c#,unit-testing,asynchronous,async-await,xunit,C#,Unit Testing,Asynchronous,Async Await,Xunit,我使用XUnit在asp.net核心代码上创建了一些单元测试 我正在尝试呼叫我的服务控制器并检查结果: [Fact] public async Task TryGetData() { //Arrange WeatherController weatherController = new WeatherController(); //Act ActionResult result = await weathe

我使用XUnit在asp.net核心代码上创建了一些单元测试

我正在尝试呼叫我的服务控制器并检查结果:

    [Fact]
    public async Task TryGetData()
    {
        //Arrange
        WeatherController weatherController = new WeatherController();

        //Act
        ActionResult result = await weatherController.Get();

        //Assert
        JsonResult jsonResult = Assert.IsType<JsonResult>(result);
        List<Prediction> predictions = Assert.IsType<List<Prediction>>(jsonResult.Value);
        Assert.NotEmpty(predictions);
        foreach (Prediction prediction in predictions)
        {
            Assert.NotEqual(default(DateTime), prediction.Date);
            Assert.NotEqual(default(double), prediction.Temperature);
        }
    }
[事实]
公共异步任务TryGetData()
{
//安排
WeatherController WeatherController=新的WeatherController();
//表演
ActionResult=等待weatherController.Get();
//断言
JsonResult JsonResult=Assert.IsType(结果);
列表预测=Assert.IsType(jsonResult.Value);
Assert.NotEmpty(预测);
foreach(预测中的预测)
{
Assert.NotEqual(默认值(DateTime),prediction.Date);
Assert.NotEqual(默认值(双精度)、prediction.Temperature);
}
}
它可以工作,但在目前温度为0的情况下,它会如预期的那样失败

但是:

  • 如果我点击debug,测试将失败,但visualstudio不会就此停止
  • 如果我设置一个断点,没有任何东西会停止
  • 我使用VS2019,Xunit 2.4.1,在resharper测试会话和VisualStudio测试会话中进行了尝试,没有改变任何东西

    支持吗?我在某个地方读到,在XUnit 1.9之前,这是不受支持的,但我有2.4.1


    你知道发生了什么吗?

    你认为失败的地方可能没有失败。在排列上放置一个断点,然后从there@Nkosi我在输出窗口的第一行上有一个断点。我终于发现,由于某种原因,我的项目调试配置没有包含调试符号,不确定为什么,我只是创建了它。