MEMark
MEMark

Reputation: 1529

NUnit ignores test when requesting mock from AutoFixture/AutoMaq

I'm using NUnit with AutoFixture, AutoMoq and the Theory attribute.

Here is my test method,

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

}

the interface

public interface I
{ }

and the attribute

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

When I build my solution the test is discovered. When I run the test the following is written to the Output window:

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)'.

When using xUnit.net the above test is run correctly. Why is not it working with NUnit?


I have the following Nuget packages installed in the test project:

I'm running the test from within Visual Studio 2013 Professional. I also tried running the test in the separate GUI runner, with the same result.

Upvotes: 2

Views: 1234

Answers (1)

Nikos Baxevanis
Nikos Baxevanis

Reputation: 11201

The following NUnit test passes in Visual Studio 2013 with the TestDriven.Net add-in:

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);
    }
}

The built-in test runner doesn't discover the above test. This looks like a bug in the test runner.

Upvotes: 3

Related Questions