Exception when switching a test from NUnit to Xunit


VS2010, Resharper 6.0, xUnit contrib revision f0a427327dca.

  1. Create a project with references to both Xunit and NUnit.
  2. Create NUnit test, marked with [Test] attribute
  3. Run this test.
  4. Change its attribute from [Test] to [Fact], so that now it becomes Xunit test.
    You get exception “Object reference not set to an instance of an object".
Reason: look at XunitTestProvider.cs, method GetOrCreateTestClass, line 159. Here you get IUnitTestElement, but in that case it is not XunitTestClassElement, it is NUnitTestFixtureElement. Probably, this is caused by some bug in ReSharper's UnitTestManager. Unfortunately, as R# 6.0 is already released this bug won't be fixed. Anyway, in XunitPsiFileExplorer, method ProcessTestClass, line 126, you should probably check that testElement is not null, otherwise you get this exception.

I would suggest you to include this scenario into test suite for integration with R# 6.1. By the way, R# has just opened EAP for 6.1, so if you have any integration problems due to inconsistency at R# side, please, contact their team as soon as possible.

Anatoly Nikitin,
JetBrains dotCover developer.
Closed Nov 28, 2011 at 10:51 PM by mattellis
Released in xunitcontrib-resharper 0.5


mattellis wrote Nov 15, 2011 at 6:27 AM

Wow, good find! The id naming scheme was the same as nunit's, so we could clash. I've now added "xunit:" to the start of the ids to prevent this. Shouldn't have any effect on saved test sessions, either.

mattellis wrote Nov 28, 2011 at 10:09 PM

Fixed in changeset 316796a713a8