NUnit 在从 AutoFixture/AutoMaq 请求模拟时忽略测试
本文关键字:测试 模拟 请求 在从 AutoFixture AutoMaq NUnit | 更新日期: 2023-09-27 17:56:43
我正在使用带有AutoFixture
、AutoMoq
和Theory
属性的NUnit
。
这是我的测试方法,
[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 自动固定件.
- 自动起订量 3.18.1
- 最小起订量 4.2.1402.2112
- NUnit 2.6.3
- NUnitTestAdapter 1.0
我正在 Visual Studio 2013 Professional 中运行测试。我还尝试在单独的 GUI 运行器中运行测试,结果相同。
以下 NUnit 测试在 Visual Studio 2013 中使用 TestDriven.Net 加载项通过:
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);
}
}
内置测试运行程序不会发现上述测试。这看起来像测试运行器中的一个错误。