.net - Xunit 以下构造函数参数没有匹配的夹具数据

标签 .net xunit

在将 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/

相关文章:

c# - 如何在 xunit 中模拟 Db 连接?

C# 格式化约定

.net - 我可以在 Windows Server 2003 上运行 .NET 4.0 Web 应用程序吗?

c# - AutoFixture.Freeze IEnumerable 模拟

c# - 从 dotnet 测试中排除命名空间

php - 用具体值模拟 atLeastOnce,其余的不重要

.net - String.Format 带符号小数,固定小数位数,无小数分隔符

.net - 为什么 Socket.BeginReceive 会丢失 UDP 数据包?

c# - 如何使用 C# 检查用户是否在 Active Directory 中具有写权限?

C# Stryker 突变框架