SpecFlow has instructions for running SpecFlow.exe from the command line。
基本上命令
specflow.exe generateall <projectFile>
如:
specflow.exe generateall BookShop.AcceptanceTests.csproj
页面不说,如果只在窗口的命令或在* nix的作品,所以你需要尝试看看。
**编辑**
这是我当前的项目一个精简的项目文件与删除所有非specflow相关的东西。它可以作为一个起点:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AF546F23-38E9-45CF-8F61-83667F708C39}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>YourNAmespace</RootNamespace>
<AssemblyName>YourAssemblyName</AssemblyName>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="TechTalk.SpecFlow">
<HintPath>..\packages\SpecFlow.1.9.0\lib\net35\TechTalk.SpecFlow.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Features\TheFeature.feature.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>TheFeature.feature</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Features\TheFeature.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>TheFeature.feature.cs</LastGenOutput>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>
鉴于SpecFlow用于.NET并且命令以“.exe”结尾,因此可以安全地假定Windows。 – 2014-09-30 16:31:17
尽管在Mono下运行SpecFlow.exe,但它需要一个项目文件作为generateAll的参数。任何想法如何生成一个最小的项目文件? – 2014-10-01 14:13:41
我已经添加了刺您可能需要@SebRose,但不知道它是否会工作。 – 2014-10-01 14:21:07