C# 如何调试异步XUnits测试?
我使用XUnit在asp.net核心代码上创建了一些单元测试 我正在尝试呼叫我的服务控制器并检查结果: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
[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的情况下,它会如预期的那样失败
但是:
你知道发生了什么吗?你认为失败的地方可能没有失败。在排列上放置一个断点,然后从there@Nkosi我在输出窗口的第一行上有一个断点。我终于发现,由于某种原因,我的项目调试配置没有包含调试符号,不确定为什么,我只是创建了它。