Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么xUnit测试抛出AggregateException?_C#_Xunit_Xunit.net - Fatal编程技术网

C# 为什么xUnit测试抛出AggregateException?

C# 为什么xUnit测试抛出AggregateException?,c#,xunit,xunit.net,C#,Xunit,Xunit.net,这是我的测试类的设置: [CollectionDefinition("MyCollection")] public class MyDefinition : ICollectionFixture<DBName> { } [Collection("MyCollection")] public class MyTestBase { protected readonly ITestOutputHelper testOutputHelper;

这是我的测试类的设置:

[CollectionDefinition("MyCollection")]
public class MyDefinition : ICollectionFixture<DBName> { }

[Collection("MyCollection")]
public class MyTestBase
{
    protected readonly ITestOutputHelper testOutputHelper;
    protected DBName db;

    public MyTestBase(ITestOutputHelper testOutputHelper, DBName db)
    {
        this.testOutputHelper = testOutputHelper;
        this.db = db;
    }
}

[Collection("MyCollection")]
public class MyTests : MyTestBase
{
    public MyTests (ITestOutputHelper testOutputHelper, DBName db) : base(testOutputHelper, db)
    {
        testOutputHelper.WriteLine(db);
    }

    [Fact]
    public void testA() { //Asserts }

    [Fact]
    public void testB() { //Asserts }
}

此设置中的缺陷是什么,为什么会产生错误。

请共享一个。是的,我很困惑,因为夹具适用于一个测试,但不适用于另一个测试。您确定
索引自动失效异常
不是来自您的夹具吗?它试图告诉你这两个问题?还有:什么是
optDB
/
OptimaDB
?代码中没有显示这些内容,它只是打印db名称,以确保整个类集合的db名称相同。将其重命名为db。。。
System.AggregateException : One or more errors occurred. (Cannot find table 0.) (The following constructor parameters did not have matching fixture data: DBName db)
---- System.IndexOutOfRangeException : Cannot find table 0.
---- The following constructor parameters did not have matching fixture data: DBName db