Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Nov 7, 2019. It is now read-only.
/SpecFlow.NetCorePublic archive

A (hopefully) temporary solution to get SpecFlow and .NET Core to play nice

License

NotificationsYou must be signed in to change notification settings

stajs/SpecFlow.NetCore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo is now archived because SpecFlow has caught up! A huge thanks to the many contributors! 🍻


⚠️SpecFlow itself (and by extension this project) is currently limited to Windows platforms with .NET Framework v4.5.1+, or non-Windows with Mono.

The problem

As at the time of writing (September 2016), theSpecFlow for Visual Studio 2015 extension does not play well with .NET Core projects.

The solution

Wait for the VS extension to support .NET Core projects. In the meantime, I present...

The (hopefully temporary) solution

Update your project:

  1. Include SpecFlow and your test framework of choice:

    • xUnit:

      <ItemGroup>  <PackageReferenceInclude="Microsoft.NET.Test.Sdk"Version="15.3.0" />  <PackageReferenceInclude="SpecFlow"Version="2.1.0" />  <PackageReferenceInclude="xunit.runner.visualstudio"Version="2.2.0" />  <PackageReferenceInclude="xunit"Version="2.2.0" /></ItemGroup>
    • NUnit(Experimental):

      <ItemGroup>  <PackageReferenceInclude="Microsoft.NET.Test.Sdk"Version="15.3.0" />  <PackageReferenceInclude="SpecFlow"Version="2.1.0" />  <PackageReferenceInclude="NUnit"Version="3.8.1" />  <PackageReferenceInclude="dotnet-test-nunit"Version="3.4.0-beta-2" /></ItemGroup>
    • MsTest(Experimental):

      <ItemGroup>  <PackageReferenceInclude="Microsoft.NET.Test.Sdk"Version="15.3.0" />  <PackageReferenceInclude="SpecFlow"Version="2.1.0" />  <PackageReferenceInclude="MSTest.TestAdapter"Version="1.1.18" />  <PackageReferenceInclude="MSTest.TestFramework"Version="1.1.18" /></ItemGroup>
  2. IncludeSpecFlow.NetCore:

    <ItemGroup>  <DotNetCliToolReferenceInclude="SpecFlow.NetCore"Version="1.3.5" /></ItemGroup>
  3. Add a precompile script:

    <TargetName="PrecompileScript"BeforeTargets="BeforeBuild">  <ExecCommand="dotnet SpecFlow.NetCore" /></Target>
  4. Build for your tests to be discovered.

    Note: there isa bug with the .NET Core CLI requiring a second build for newly added files to be discovered.

Cross platform using Mono

This has been tested on Windows, Ubuntu and macOS (High Sierra). It works in exactly the same way except it doesn’t use DotNetCli because it doesn’t work cross platform. Instead we call dotnet-SpecFlow.NetCore.exe directly from the package, this is why we need an extra PackageReference to SpecFlow.NetCore.

You also need to reference SpecFlow 2.2 or higher due to aMono specific bug in SpecFlow.

<PropertyGroup>      <SpecFlowNetCoreVersion>1.3.2</SpecFlowNetCoreVersion></PropertyGroup>  <ItemGroup>   <PackageReferenceInclude="SpecFlow.NetCore"Version="$(SpecFlowNetCoreVersion)" />      <PackageReferenceInclude="SpecFlow"Version="2.2.0" />   <PackageReferenceInclude="xunit.runner.visualstudio"Version="2.2.0" />   <PackageReferenceInclude="xunit"Version="2.2.0" /></ItemGroup><TargetName="PrecompileScript"BeforeTargets="BeforeBuild">  <ExecCommand="mono $(NuGetPackageRoot)specflow.netcore/$(SpecFlowNetCoreVersion)/lib/$(TargetFramework)/dotnet-SpecFlow.NetCore.exe" /></Target>

.NET Core & target frameworks

SpecFlow itself is currently limited to Windows platforms with full .NET Framework v4.5.1+. This means that two of the most commontarget frameworks are unsupported:

  • .NET Standard (unsupported)
  • .NET Core Application (unsupported)
  • .NET Framework

For.NET Framework, the following Target Framework Monikers (TFMs) are officially supported:

  • net46
  • net461

TFMs ofnet451 and above should support SpecFlow and this project, but have not been officially tested.

Visual Studio

Test Explorer

image

Samples

If you build thesamples solution, you should see.feature.cs files and anapp.config being generated for each test framework.

Background

About

A (hopefully) temporary solution to get SpecFlow and .NET Core to play nice

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp