我正在尝试升级到 xUnit 2 beta(主要是因为更好的测试发现),但遇到了 IUseFixture<>
问题:
public abstract class TestCaseBase : IUseFixture<SelfHostFixture>
{ /*common stuff here*/ }
public class Controller1Test : TestCaseBase {}
public class Controller2Test : TestCaseBase {}
我发现新的
IClassFixture<>
几乎符合我的要求,除了这个 fixture 会为每个派生类(Controller1Test
, Controller2Test
) 分别创建和销毁,而不是只创建和销毁一次。嗯,我可以把 IClassFixture<SelfHostFixture>
声明从基类移到每个测试类,但为什么要多次设置/销毁服务器?ICollectionFixture<>
对我没有用(fixture 的构造函数从未被调用)。基本上,我想要的是:
- "Per run" fixture (必须在每次测试运行时只实例化一次)
- 启用并行运行,因为我的测试只是无状态的 HTTP 调用(我认为
ICollectionFixture<>
根本不能工作,因为同一集合内的测试不能并行运行,对吗?)