2

我正在使用withNUnitAutoFixture属性。AutoMoqTheory

这是我的测试方法,

[TestFixture]
public class TestClass
{
    [Theory, AutoMoqData]
    public void TestI(I i)
    { }

}

界面

public interface I
{ }

和属性

public class AutoMoqDataAttribute : AutoDataAttribute
{
    public AutoMoqDataAttribute()
        : base(new Fixture().Customize(new AutoMoqCustomization()))
    { }
}

当我构建我的解决方案时,会发现测试。当我运行测试时,以下内容将写入输出窗口:

NUnit 1.0.0.0 executing tests is started
Run started: [...].Test.dll
NUnit 1.0.0.0 executing tests is finished
Test adapter sent back a result for an unknown test case. Ignoring result for 'TestI(Mock<TestClass+I:1393>.Object)'.

使用xUnit.net上述测试时运行正常。为什么不使用它NUnit


我在测试项目中安装了以下 Nuget 包:

  • 自动夹具 3.18.1
  • AutoFixture.AutoMoq 3.18.1
  • 起订量 4.2.1402.2112
  • NUnit 2.6.3
  • NUnitTestAdapter 1.0

我在 Visual Studio 2013 Professional 中运行测试。我还尝试在单独的 GUI 运行器中运行测试,结果相同。

4

1 回答 1

3

以下 NUnit 测试通过TestDriven.Net插件在 Visual Studio 2013 中通过:

internal class AutoMoqDataAttribute : AutoDataAttribute
{
    internal AutoMoqDataAttribute()
        : base(
            new Fixture().Customize(
                new AutoMoqCustomization()))
    {
    }
}

public interface IInterface
{ 
}

public class Tests
{
    [Test, AutoMoqData]
    public void IntroductoryTest(IInterface i)
    {
        Assert.NotNull(i);
    }
}

内置测试运行器没有发现上述测试。这看起来像是测试运行器中的一个错误。

于 2014-04-09T13:40:43.770 回答