xUnit v2 IUseFixture <>替换

Use*_*rol 12 .net c# testing xunit xunit.net

我正在尝试升级到xUnit 2 beta(主要是因为更好的测试发现),但偶然发现IUseFixture<>:

public abstract class TestCaseBase : IUseFixture<SelfHostFixture> 
{ /*common stuff here*/ }

public class Controller1Test : TestCaseBase {}

public class Controller2Test : TestCaseBase {}
Run Code Online (Sandbox Code Playgroud)

我发现new IClassFixture<>几乎就是我需要的东西,除了为每个后代类(Controller1Test,Controller2Test)而不是一次创建/处理fixture .好吧,我可以IClassFixture<SelfHostFixture>从基地向每个测试类移动声明,但为什么我会多次设置/部署我的服务器?ICollectionFixture<>没有为我工作(夹具的ctor从未被解雇).

基本上,我想要的是:

  1. "每次运行"夹具(每次测试运行必须只实例化一次)
  2. 启用并行运行,因为我的测试只是无状态HTTP调用(我认为ICollectionFixture<>根本不起作用,因为同一集合中的测试不能并行运行,对吧?)

我错过了什么?

Tim*_*ith 7

答:使用ICollectionFixture

请参见http://xunit.github.io/docs/shared-context.html