Visual Studio Express does not support the test driven developers. The Express editions do not have any integrated testing framework like MSBuild and you cannot add-in one, as addins/plugins are disallowed. Also there is a limitation to attach the debugger to a process, so you cannot easily debug an external test runner like Gallio or NUnit.
Fortunately, there are some workarounds. Here is the summarized result of my research on the topic of running and debugging tests with Visual Studio Express.
- To run tests you can
- use a standalone test runner and execute it against an assembly with your tests;
- configure the Visual Studio to execute a test runner through the Tools menu like Martijn Dijksterhuis suggested.
- To debug tests you can
- convert your test library project into console or Windows Form application and point it to your favorite test runner as it shown in Steve Dunn's blog post;
- manually edit the project file to specify a test runner as external program in the Start Action for your test assembly in a similar way as Pål Fossmo or Jeremy Tammik described.
I prefer the last workaround, modification of the msbuild project file. The following piece of .csproj file allows me to integrate MbUnit test runner into Microsoft Visual C# 2010 Express.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<StartAction>Program</StartAction>
<StartProgram>$(MSBuildProjectDirectory)\..\Tools\MbUnit\Gallio.Echo.exe</StartProgram>
<StartArguments>$(MSBuildProjectDirectory)\$(OutputPath)\$(AssemblyName).dll /runner:IsolatedAppDomain /report-type:Text /show-reports</StartArguments>
<StartWorkingDirectory>$(MSBuildProjectDirectory)\$(OutputPath)</StartWorkingDirectory>
</PropertyGroup>
The StartAction, StartProgram, StartArguments and StartWorkingDirectory are related to the Start Action feature hidden in the Express edition. The StartProgram specifies the console test runner, Gallio Echo; the StartArguments property includes what to test, and how to run the test runner (note the "/runner:IsolatedAppDomain" argument that allows to debug the tests) and report type.
It is also possible to use GUI test runner, Gallio Icarus. Just for debugging it is necessary to manually set the IsolatedAppDomain (Gallio Control Panel > Preferences tab > Icarus > Runner > Test Runner Factory) as it is not possible to specify through the command line.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
...
<StartAction>Program</StartAction>
<StartProgram>$(MSBuildProjectDirectory)\..\Tools\MbUnit\Gallio.Icarus.exe</StartProgram>
<StartArguments>$(MSBuildProjectDirectory)\$(OutputPath)\$(AssemblyName).dll</StartArguments>
...
</PropertyGroup>
Press F5 and enjoy this free solution.
Updates
- Removed spaces in XML values. (20.4.2011)