views:

747

answers:

1

Hi,

Few days ago I watched a BDD screencast by Rob Conery. In the video he showed how to use MSpec, so I downloaded it and played with the bits. What I want now is to integrate MSpec with MS Build, but I don't know how... I use TFS team build as my CI server - Can you help me to integrate MSpec with MSBuild?

Thanks!

+4  A: 

At the moment the easiest way is to just Exec it.

 <Target Name="RunSpecs">
    <PropertyGroup>
      <MSpecCommand>
        lib\machine\specifications\Machine.Specifications.ConsoleRunner.exe $(AdditionalSettings) path\to\your\project\bin\Debug\Your.Project.Specs.dll path\to\your\other\project\bin\Debug\Your.Other.Project.dll 
      </MSpecCommand>
    </PropertyGroup>
    <Message Importance="high" Text="Running Specs with this command: $(MSpecCommand)"/>
    <Exec Command="$(MSpecCommand)" />
  </Target>

Edit: Notice Additional Settings, you can call into the target like this:

    <MSBuild Projects="yourmsbuild.msbuild" Targets="RunSpecs" Properties="AdditionalSettings=-s -t -i &quot;web&quot; --html Specs\Specs.html"/>

If you pass --teamcity as an argument it outputs teamcity specific log data so TeamCity will track your tests.

Machine.Specifications
Copyright (C) 2007, 2008

Usage: mspec-runner.exe [options] <assemblies>
Options:
  -i, --include     Executes all specifications in contexts with these comma delimited tags. Ex. -i "foo,bar,foo_bar"
  -x, --exclude     Exclude specifications in contexts with these comma delimited tags. Ex. -x "foo,bar,foo_bar"
  -t, --timeinfo    Shows time-related information in HTML output
  -s, --silent      Suppress console output
  --teamcity        Reporting for TeamCity CI integration.
  --html <PATH>     Outputs an HTML file(s) to path, one-per-assembly w/ index.html (if directory, otherwise all are in
one file)
  -h, --help        Shows this help message
aaronjensen
Note that when you are doing this with NAnt use arg line="assembly1 assembly2" not arg value (otherwise you will get a nice error that is very non-obvious)
Neal