如何将MSpec与MS Build集成?

Pav*_*lov 10 .net msbuild bdd continuous-integration mspec

前几天我看了一个BDD截屏通过罗布科纳.在视频中他展示了如何使用MSpec,所以我下载了它并使用了比特.我现在想要的是将MSpec与MS Build 集成,但我不知道如何...我使用TFS团队构建作为我的CI服务器 - 你能帮助我将MSpec与MSBuild 集成吗?

谢谢!

Aar*_*sen 7

目前最简单的方法就是执行它.

 <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>
Run Code Online (Sandbox Code Playgroud)

编辑:注意其他设置,您可以像这样调用目标:

    <MSBuild Projects="yourmsbuild.msbuild" Targets="RunSpecs" Properties="AdditionalSettings=-s -t -i &quot;web&quot; --html Specs\Specs.html"/>
Run Code Online (Sandbox Code Playgroud)

如果您将--teamcity作为参数传递,它会输出teamcity特定的日志数据,因此TeamCity将跟踪您的测试.

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
Run Code Online (Sandbox Code Playgroud)