Reputation: 41823
I'm aware there are dozens of questions about this and blog after blog post but can someone put the simplest answer (or link to the existing question if there is an appropriate answer) to get the following working on Visual Studio 2005:
NUnit tests execute on Visual Studio regular build (e.g. the absolute minimum changes to existing *.proj file to get NUnit included in MSBuild compile). If it doesn't overcomplicate things, is there a good way to use the MSBuild Community Tasks Project as a binary rather than installed on each dev machine?
Test failures show in error list/warnings.
Test failures halt release compilation.
Thanks for any help!
Upvotes: 0
Views: 619
Reputation: 5946
To do this properly you probably want some kind of Continuous Integration Server like TeamCity or Cruise Control .
You can then add nUnit tests to your MsBuild script using the following
<!--BEGIN RUNNING UNIT TESTS-->
<Choose>
<When Condition=" '$(Configuration)' == 'Release' ">
<ItemGroup>
<TestAssemblies Include="$(BuildDir)\Builds\Release\BusinessLayer.Tests.dll" />
<TestAssemblies Include="$(BuildDir)\Builds\Release\ResourceAccessLayer.Tests.dll" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<TestAssemblies Include="$(BuildDir)\Builds\Debug\BusinessLayer.Tests.dll" />
<TestAssemblies Include="$(BuildDir)\Builds\Debug\ResourceAccessLayer.Tests.dll" />
</ItemGroup>
</Otherwise>
</Choose>
<UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)" />
<Target Name="Test" DependsOnTargets="Build">
<NUnit NUnitVersion="NUnit-2.4.6" Assemblies="@(TestAssemblies)" />
</Target>
<!--RUNNING UNIT TESTS-->
You can add the condition to the target that if the configuration is Release and the task fails then then the build fails.
I think this should cover points 1 and 3
EDIT: The other way to do it would be to run the nUnit tests using the pre/post build step in Visual Studio, this and this may help.
Hope this helps
Upvotes: 1
Reputation: 10003
you may find this list useful: http://groups.google.com/group/nunit-discuss
Upvotes: 1