Dot-Net

如何將 MSpec 與 MS Build 集成?

  • June 2, 2009

幾天前,我觀看了Rob Conery的BDD 截屏影片。在影片中,他展示瞭如何使用MSpec,所以我下載了它並使用了這些位。我現在想要將MSpec與 MS Build 集成,但我不知道如何……我使用 TFS 團隊建構作為我的 CI 伺服器 - 你能幫我將MSpec與 MSBuild 集成嗎?

謝謝!

目前最簡單的方法是執行它。

<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>

編輯:注意附加設置,您可以像這樣呼叫目標:

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

如果您將 –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

引用自:https://stackoverflow.com/questions/938347