Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 425
MW_dev Avatar asked Jan 08 '11 07:01

MW_dev


2 Answers

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.

like image 50
Michiel van Oosterhout Avatar answered Sep 21 '22 08:09

Michiel van Oosterhout


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.

like image 26
MW_dev Avatar answered Sep 19 '22 08:09

MW_dev