2014-09-28 30 views
2

我有一个简单的C#应用​​程序,我想从SpecFlow验收测试中驱动。如何从Mono上的命令行运行SpecFlow?

应用程序及其场景必须从Mono编写,构建和运行。我不得不使用简单的文本编辑器(而不是IDE)和命令行。

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

有没有人有任何指示或说明可能有帮助?

回答

0

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

鉴于SpecFlow用于.NET并且命令以“.exe”结尾,因此可以安全地假定Windows。 – 2014-09-30 16:31:17

+0

尽管在Mono下运行SpecFlow.exe,但它需要一个项目文件作为generateAll的参数。任何想法如何生成一个最小的项目文件? – 2014-10-01 14:13:41

+0

我已经添加了刺您可能需要@SebRose,但不知道它是否会工作。 – 2014-10-01 14:21:07