如何在Mono上从命令行运行SpecFlow?

时间:2014-09-28 19:34:57

标签: c# mono specflow

我有一个简单的C#应用​​程序,我想从SpecFlow验收测试开始。

应用程序及其方案必须从Mono编写,构建和运行。

我必须使用简单的文本编辑器(不是IDE)和命令行。

主要问题似乎是生成'背后的代码。功能文件。我知道你可以从MonoDevelop做到这一点,但我不能使用MonoDevelop(至少不能直接使用)。我可以从命令行调用MonoDevelop来生成'背后的代码吗?

有没有人有任何可能有帮助的指针/说明?

1 个答案:

答案 0 :(得分:0)

SpecFlow has instructions for running SpecFlow.exe from the command line

基本上命令是

specflow.exe generateall <projectFile>

例如:

specflow.exe generateall BookShop.AcceptanceTests.csproj

页面没有说明Windows中的命令是否仅适用于* 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>