Let ReSharper and xUnit work together

Getting the ressources First at all download xUnit http://xunit.codeplex.com/releases/ xUnit Contrib ReSharper http://xunitcontrib.codeplex.com/releases/ Thi...

Getting the ressources

First at all download

Installation und Configuration

Unzip both archives.

xUnit part

Configure the code to use xUnit

Normally I prefer a single checkout point for my developing solution – this whole bundle I name DevTree. One of the top folders in the hierarchy of this DevTree is a lib-Folder. Beneath this folder all of the 3rd party libs which I use in my solution are located – all of them in an own folder. So I copy xunit.dll to a folder <DevTree-TopPoint>\lib\xUnit.

Now its time to use xUnit in a fixture – simply by referencing this “local” xunit.dll and using the attribute [Fact] on a test method.

xUnit-Contrib ReSharper part

As you could recognize – this test method does not get the green bubbles from ReSharper to start the test. Here comes the contrib project into play. It empowers ReSharper to run xUnit-bases test methods.

Installing the ReSharper plugin

If VS runs, close it.

You could copy the contrib stuff from the folder fitting to your ReSharper-version to

  • the ReSharper machine-wide plugin-folder C:\Program Files (x86)\JetBrains\ReSharper\v5.1\Bin\Plugins\xUnit Contrib ReSharper
  • or your user-sepcific plugin-folder %AppData%\JetBrains\ReSharper\v5.1\vs10.0\Plugins\xUnit Contrib ReSharper (please consider the correct VS-version in the folder-structure – vs10.0 stands for VS2010)

Maybe you must unblock this files before copying – otherwise they are not accessible from applications (right mouse > Unblock).

http://xunitcontrib.codeplex.com/wikipage?title=FaqReSharperBlockedFiles

Verify the runnig plugin under VS-menu ReSharper > Plugins – there should be a checked entry “xUnit.net unit test provider …”

To give ReSharper some annotations hints, first copy the xunit.xml to the external annotations folder of ReSharper.

For my version this is: C:\Program Files (x86)\JetBrains\ReSharper\v5.1\Bin\ExternalAnnotations

If you are an extensive user of ReSharpers LiveTemplates (and frankly – you should!) – import the Live Templates delivered with xUnit Contrib ReSharper.

There are two versions xunit-xe.xml and xunit-xa.xml. Only one of them you should use, depending on what other unit testing frameworks and Live Templates are additionally installed. I took the xe variant.

I edited the file and attributed the type of template file – so the first tag changed

  • from <TemplatesExport>
  • to <TemplatesExport family=“Live Templates”>.