MW_dev
MW_dev

Reputation: 2164

How do I configure visual studio to run xUnit.net tests?

I have configured Visual Studio 2010 to debug xUnit.net tests by setting the Project Settings | Debug | Start External Program to run the xUnit.net console runner.

This works OK but only when providing the complete path to the test project dll via the Command Line Arguments eg: "c:\development\TestProject.dll"

I have tried using $(BinDir)$(TargetName)$(TargetExt) as parameters via the Command Line Arguements section but it does not work. Any suggests on how I can avoid the explicit/full path?

Upvotes: 11

Views: 5013

Answers (4)

MW_dev
MW_dev

Reputation: 2164

This answer was given before James' and Brad's awesome work with xUnit.net Runners. See michielvoo's answer below.

To avoid the problem of explicitly giving the library name one can use cmd.exe with command line arguements: /C xunit.console.exe $(BinDir)$(TargetName)$(TargetExt)

Check Use Output Window

Use the Tools|Options|Keyboard configuration to assign a hot key.

Upvotes: 6

Michiel van Oosterhout
Michiel van Oosterhout

Reputation: 23084

This is what I use in my .csproj file to run the xUnit GUI runner as the start action:

<PropertyGroup>
  <StartAction>Program</StartAction>
  <StartProgram>$(MSBuildProjectDirectory)\..\..\Packages\xunit.runners.1.9.1\tools\xunit.gui.clr4.exe</StartProgram>
  <StartArguments>"$(MSBuildProjectDirectory)\$(OutPutPath)$(AssemblyName).dll"</StartArguments>
</PropertyGroup>

For this to work, all you have to do is install the xUnit.net Runners NuGet package:

PM> Install-Package xunit.runners

The only downside so far, is that it's version specific, so every time you update the NuGet package to latest, you should update this configuration to point to the correct runner.

Upvotes: 6

Christian Horsdal
Christian Horsdal

Reputation: 4932

A alternative route is use a VS plugin as testrunner. For instance ReSharper.

Upvotes: 2

John
John

Reputation: 541

I simply type the full name of the assembly thats all.

Under command line arguments: SharedDataBridge.Tests.dll

Upvotes: 0

Related Questions