Autofixture AutoData error - No arguments were provided

2.5k views Asked by At

I'm trying to use the AutoData feature in AutoFixture for my NUnit tests in the following way:

[Test]
[AutoData]
public void PharmaciesAndDelegatesShouldBeLinkedEachOther(string s) {
    ...
}

However, I'm receiving the following error when running the test. Everything else in the test work correctly as long as I don't pass that parameter:

Result Message: No arguments were provided.

What am I doing wrong?

2

There are 2 answers

0
David Jiménez Martínez On BEST ANSWER

Weird enough, it seems that the NUnitTestAdapter package is not compatible with Autofixture AutoData attribute... I installed TestDriven.Net and ran the tests with it and AutoData works perfectly, feeding the parameters to the method with no problem.

Thanks for all your answers!

0
sgnsajgon On

Make sure that you have installed the latest version of NUnit (2.6.3) NuGet package in your tests project. If you are using the native NUnit runner (console or GUI), also make sure that you are using the latest version of it (2.6.3)

Then, If you have AutoFixture.Nunit2 package installed in your tests project, and you use the latest NUnit 2.6.3 and Resharper version at least 8.1, you need to manually add binding redirect to app.config file of your tests project (as was stated in the readme.txt file what was opened after AutoFixture.Nunit2 package installation):

<dependentAssembly>
    <assemblyIdentity name="nunit.core.interfaces" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.6.3.13283" newVersion="2.6.3.13283" />
</dependentAssembly>

If you don't have app.config file in you tests project, please add one, and paste the following content:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
          <assemblyIdentity name="nunit.core.interfaces" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-2.6.3.13283" newVersion="2.6.3.13283" />
      </dependentAssembly> 
    </assemblyBinding>
  </runtime>
</configuration>

Aferward, check if you have added the following class in your tests project ( Should be added during installation of AutoFixture.Nunit2 package as LocalAddin.cs file )

using NUnit.Core.Extensibility;

namespace Test.Project
{
    [NUnitAddin]
    public class LocalAddin : Ploeh.AutoFixture.NUnit2.Addins.Addin
    {   
    }
}

That's all. I'm using VS2013, NUnit 2.6.3, AutoFixture.Nunit2 3.21.1, Resharper tests runner and native NUnit runners (console and GUI), and it works great.