Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoFixture's AutoData attribute with Xunit throws System.InvalidOperationException

I'm using xunit v2.1.0, xunit.extensions v1.8.0.1549, AutoFixture v3.40.0, AutoFixture.Xunit v3.40.0 and I have this simple trivial test that uses AutoData

using Ploeh.AutoFixture.Xunit;
using Xunit;

namespace Tests
{
    public class ToolTests
    {
        [Theory, AutoData]
        public void Test(int foo)
        {
            Assert.NotEqual(0, foo);
        }
     }
}  

And the error that I get in Resharper (v9.2) test runner is

System.InvalidOperationException No data found for Tests.ToolTests.Test Exception doesn't have a stacktrace

I've noticed that xunit.extensions is not the last version (currently v2.0.0), but when I try to update given nuget package I get error:

Unable to resolve dependencies. 'xunit.extensions 2.0.0' is not compatible with 'AutoFixture.Xunit 3.40.0 constraint: xunit.extensions (≥ 1.8.0.1549 && < 2.0.0)'

Any clues why this is happening?

like image 584
dragan.stepanovic Avatar asked Mar 08 '16 19:03

dragan.stepanovic


1 Answers

You have to use the AutoFixture.Xunit2 package, instead of the AutoFixture.Xunit when you're using xUnit 2.0 or above.

like image 94
Marcio Rinaldi Avatar answered Sep 22 '22 12:09

Marcio Rinaldi