Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run nunit with msbuild from VS2010

please tell me how to run nunit with msbuild. I am using TFS for code integration and VS2010 .

like image 215
Rajesh Avatar asked Jan 05 '11 14:01

Rajesh


People also ask

How do I use NUnit console runner in Visual Studio?

Just add NUnit tests to your project and they will now magically show up in the Test Explorer and run when you hit the > button. Instead of the NuGet package, you'll need to use the test runner from the Visual Studio Gallery or from the Tools -> Extensions and Updates menu.


1 Answers

You probably want to integrate NUnit with TFSBuild and not MSBuild since you are using Team Foundation Server.

You will need MSBuild tasks to be able to run NUnit as explained in the three following tutorials:

  • Using NUnit and NCover with TFS Build
  • Integrate Nunit test into a Tfs build
  • MSBuild with NUnit

The easiest way is to use the MSBuild Community Tasks where you already have a NUnit task ready to be used and you only will need to add a target to your msbuild file like so:

<Target Name="RunTests">  
    <!-- Run Unit tests -->  
    <CreateItem Include="$(OutDir)*.Tests.dll">  
      <Output TaskParameter="Include" ItemName="TestAssembly" />  
    </CreateItem>  
    <NUnit ToolPath="..\Tools\NUnit" DisableShadowCopy="true" Assemblies="@(TestAssembly)" />  
  </Target>
like image 143
Dennis G Avatar answered Sep 19 '22 14:09

Dennis G