使用 IClassFixture 时输出测试结果 XUnit .net core
Output Test results XUnit .net core when using IClassFixture
我一直使用 Nunit,现在转向 XUnit。
当我没有实现IClassFixture
时,我使用ITestOutputHelper
成功了,例如:
public myClassTest(ITestOutputHelper outputHelper)
{
this.outputHelper = outputHelper;
}
然而,当我实施 IClassFixture
时,我找不到注入 ITestOutputHelper
的方法。
我无法实现 ITestOutputHelper 的示例
public class MyIntegrationTests : IClassFixture<TestServerFixture<Startup>>
{
public MyIntegrationTests (TestServerFixture<Startup> testServerFixture)
{
client = testServerFixture.Client;
}
}
我是不是漏掉了显而易见的东西?
它应该通过做来工作:
public class MyIntegrationTests : IClassFixture<TestServerFixture<Startup>>
{
public MyIntegrationTests (TestServerFixture<Startup> testServerFixture, ITestOutputHelper outputHelper)
{
client = testServerFixture.Client;
this.outputHelper = outputHelper;
}
}
as ITestOutputHelper
,所有声明的 Class 和 Shared fixtures 都可以通过这种方式提供。
您在输出 window (Ctrl-Alt-O) 的 测试 面板中给出了什么信息?
我一直使用 Nunit,现在转向 XUnit。
当我没有实现IClassFixture
时,我使用ITestOutputHelper
成功了,例如:
public myClassTest(ITestOutputHelper outputHelper)
{
this.outputHelper = outputHelper;
}
然而,当我实施 IClassFixture
时,我找不到注入 ITestOutputHelper
的方法。
我无法实现 ITestOutputHelper 的示例
public class MyIntegrationTests : IClassFixture<TestServerFixture<Startup>>
{
public MyIntegrationTests (TestServerFixture<Startup> testServerFixture)
{
client = testServerFixture.Client;
}
}
我是不是漏掉了显而易见的东西?
它应该通过做来工作:
public class MyIntegrationTests : IClassFixture<TestServerFixture<Startup>>
{
public MyIntegrationTests (TestServerFixture<Startup> testServerFixture, ITestOutputHelper outputHelper)
{
client = testServerFixture.Client;
this.outputHelper = outputHelper;
}
}
as ITestOutputHelper
,所有声明的 Class 和 Shared fixtures 都可以通过这种方式提供。
您在输出 window (Ctrl-Alt-O) 的 测试 面板中给出了什么信息?