在将 XUnit 用于 .NET 1.0 框架 net46 时,我不断收到此错误。
The following constructor parameters did not have matching fixture data
我看过这个帖子:Collection fixture won't inject并严格按照此处所述的有关收集夹具的说明进行操作:
http://xunit.github.io/docs/shared-context.html#collection-fixture
似乎没有任何效果。
对可能导致这种情况的任何建议?
最佳答案
就我而言,我必须在测试类上实现 IClassFixture<> 接口(interface)。
public class MyTests : IClassFixture<QueryTestFixture>
在我将 QueryTestFixture 移动到另一个项目后,Class 属性停止工作
[Collection("QueryCollection")]
这与夹具类中的实现相关联(见下文)
[CollectionDefinition("QueryCollection")]
public class QueryCollection : ICollectionFixture<QueryTestFixture> { }
我尝试了许多替代方法来解决这个问题,但最终 reading the xunit.net explanation about shared context.这提供了一个解决方案。
关于.net - Xunit 以下构造函数参数没有匹配的夹具数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39440942/