Resharper 6.1 RTM test runner fail on xunit above 1.7

Topics: ReSharper test runner
Jan 17, 2012 at 8:18 PM

1) Source code for my tests is from Dependency Injection in .NET, download from http://www.manning.com/seemann/

The results mentioned here are for one solution: AssortedCodeSnippets. The original source distributed with xunit 1.7 and Resharper test runner runs with 100% success. I am running latest Resharper 6.1 RTM and VS2010 Ultimate with current SP1. Attempts to update xunit 1.7 (only) to any higher version fails.

2) general steps to update xunit beyond 1.7:

  original book code, in solution AssortedCodeSnippets, remove contents under packages folder, remove AssortedCodeSnippetsUnitTest invalid references

  use nuget to add references to AssortedCodeSnippetsUnitTest project

  run Resharper tests, the higher version xunit the more tests failing.

3) nuget steps (example for xunit 1.8.0.1545, but even worse results for 1.8.0.1549 and 1.9)

set Default project: AssortedCodeSnippetsUnitTest
Install-Package autofixture -Version 2.0
Install-Package moq -Version 3.1.416.3 (dependency)
Install-Package autofixture.automoq -Version 2.0
Install-Package xunit -Version 1.8.0.1545 (dependency)
Install-Package xunit.extensions -Version 1.8.0.1545 (dependency)
(auto updated) Install-Package xunit -Version 1.8.0.1549
Install-Package autofixture.xunit -Version 2.0

I found the above method was the simplest reproducible case, scientifically changing the *minimum* number of things. You can reverse the test and reload xunit v1.7 instead and Resharper 6.1 RTM will revert to working 100%. The *reason* I am mentioning is because I want latest xunit possible and 1.7 is no longer available on codeplex (only nuget).

Results:

Open file AbstractFactory\Route\RouteControllerTest.cs,
  resharper error "Theory" is not an attribute,
  fix reload Resharper (toggle key shortcut in my case), no code change fix

Resharper Test runner failed - Resharper test GUI, passed 14 failed 18 (run all tests, no hanging tests). Note - versions above 1.8.0.1545 hang and more tests fail.

Resharper Test Runner errors types:

(1) half 1.8.0.1545
System.IO.FileLoadException: Could not load file or assembly 'xunit, Version=1.8.0.1545,

Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's

manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

(2) half 1.6.1.1521 or 1.7.0.1540
System.IO.FileLoadException: Could not load file or assembly 'xunit.extensions, Version=1.6.1.1521,

Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's

manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

System.IO.FileLoadException: Could not load file or assembly 'xunit.extensions, Version=1.7.0.1540,

Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's

manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Coordinator
Jan 18, 2012 at 12:52 PM

Hmm. Looks like you're mixing and matching versions in your assembly references. The test project comes with a binding redirect from xunit.extensions 1.6.1.1521 to 1.7.0.1540. This is required because the Ploeh.AutoFixture.Xunit assembly in the autofixture.xunit package references xunit.extensions 1.6.1.1521, while the xunit packages are at 1.7.0.1540 (not quite sure why it's shipped like this, to be honest).

Updating just the xunit packages to 1.8.0.1545 (and 1.8.0.1549) doesn't affect the binding redirect, and it still tries to find either 1.7.0.1540 or 1.6.1.1521. If you update the autofixture packages, they move on to version 2.7.2 (from 2.0) and use the latest xunit packages.

Basically, it's not the runner that's failing, it's the CLR that can't find the mixed versions of the assemblies you're trying to reference.

Jan 18, 2012 at 5:21 PM

@mattellis

Thank you for quick reply. Pointing out the App.config binding redirect helps me.

I am working to correct the book's test code issues using newer(est) libraries, get all working with Resharper test runner.

Will advise of my results.

Have a great week!

Jan 18, 2012 at 6:11 PM

@mattellis

Success, 100% with Resharper GUI runner on latest version 1.9 xunit & xunit.extensions. Thank you.

## steps
set Default project: AssortedCodeSnippetsUnitTest
Install-Package autofixture
Install-Package moq -Version 3.1.416.3
Install-Package autofixture.automoq
Install-Package xunit
Install-Package xunit.extensions
Install-Package autofixture.xunit
get-package

PM> get-package

Id                             Version                    
--                             -------
AutoFixture                    2.7.2 
AutoFixture.AutoMoq            2.7.2 
AutoFixture.Xunit              2.7.2 
Moq                            3.1.416.3
xunit                          1.9.0.1566
xunit.extensions               1.9.0.1566

## old App.config (FAIL)


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="xunit.extensions" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
        <bindingRedirect oldVersion="1.6.1.1521" newVersion="1.7.0.1540" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

## new App.config (PASS)

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="xunit.extensions" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
        <bindingRedirect oldVersion="1.6.1.1521" newVersion="1.9.0.1566" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

result:
  pass - Resharper test GUI, passed 32 failed 0 (run all tests, no hangs).


## notes

The latest moq version is 4.0.10827, and it does *not* work with this solution/project's libraries.
Do *not* nuget install default moq, e.g.

## steps (FAIL)
set Default project: AssortedCodeSnippetsUnitTest
Install-Package moq
get-package moq

Id                             Version
--                             -------
Moq                            4.0.10827

result:
  failed - Resharper test GUI, passed 14 failed 18 (run all tests, no hangs). Same 18 errors:

System.InvalidOperationException: An exception was thrown while getting data for theory
Ploeh.Samples.AssortedCodeSnippetsUnitTest.AbstractFactory.Route.RouteControllerTest.GetRouteReturnsCorrectRoute:
System.IO.FileLoadException: Could not load file or assembly 'Moq, Version=3.1.416.3, Culture=neutral,
PublicKeyToken=69f491c39445e920' or one of its dependencies. The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Moq, Version=3.1.416.3, Culture=neutral, PublicKeyToken=69f491c39445e920'
   at Ploeh.AutoFixture.AutoMoq.MockPostprocessor.Create(Object request, ISpecimenContext context)
   at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.<>c__DisplayClass6.<Create>b__1(ISpecimenBuilder b)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<DefaultIfEmptyIterator>d__a5`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.<>c__DisplayClass6.<Create>b__1(ISpecimenBuilder b)
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.<DefaultIfEmptyIterator>d__a5`1.MoveNext()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request, ISpecimenContext context)
   at Ploeh.AutoFixture.FreezingCustomization.Customize(IFixture fixture)
   at Ploeh.AutoFixture.Fixture.Customize(ICustomization customization)
   at Ploeh.AutoFixture.Xunit.AutoDataAttribute.CustomizeFixture(ParameterInfo p)
   at Ploeh.AutoFixture.Xunit.AutoDataAttribute.GetData(MethodInfo methodUnderTest, Type[] parameterTypes)
   at Xunit.Extensions.TheoryAttribute.<GetData>d__7.MoveNext()
   at Xunit.Extensions.TheoryAttribute.EnumerateTestCommands(IMethodInfo method)

Jan 19, 2012 at 4:39 PM

Now, even got it working with moq v4.0.10827, details at:

http://www.manning-sandbox.com/thread.jspa?threadID=48155&tstart=0

Thanks all for your BIG help. :)