mardi 31 mai 2016

Attribute defined test data with Nunit, AutoFixture, NSubstitute and AutoSubstituteDataAttribute

I like the option to define tests using attributes. However, I must be doing something wrong. I have installed the packages:

<packages>
  <package id="AutoFixture" version="3.46.0" targetFramework="net451" />
  <package id="AutoFixture.AutoNSubstitute" version="3.46.0" targetFramework="net451" />
  <package id="AutoFixture.NUnit3" version="3.46.0" targetFramework="net451" />
  <package id="NSubstitute" version="1.10.0.0" targetFramework="net451" />
  <package id="NUnit" version="3.2.1" targetFramework="net451" />
</packages>

Single substituted parameters go through:

[Theory, AutoSubstituteData]
public void Test_Single([Substitute] Service svc)
{
     // executed, shown as success
}

While mixing substitution and some other values fails:

[Theory, AutoSubstituteData]
public void Test_Mixed(int version, string name, [Substitute] IService svc)
{
     // not executed, shown as inconclusive
}

The test output says:

NUnit Adapter 3.0.10.0: Test execution complete

Test adapter sent back a result for an unknown test case. Ignoring result for 'Test_Mixed(150,"name04f0cd50-e89f-4a8f-db6-dab69b58e98e",Castle.Proxies.IServiceProxy)'.

How do I get this to work in VS2015 or in general with NUnit 3x?

Aucun commentaire:

Enregistrer un commentaire