Getting Started

Posted on:

SpecFlow aims at bridging the communication gap between domain experts and developers by binding business readable behavior specifications and examples to the underlying implementation.

Our mission is to provide a pragmatic and frictionless approach to Specification-By-Example for .NET projects.

SpecFlow also supports the concepts of Acceptance Test Driven Development (ATDD) and Behavior Driven Development (BDD), which are often used synonymously with Specification-By-Example.

Installation

In order to install everything you need, you have to install the IDE integration and setup your project to work with SpecFlow.

Install IDE Integration

The installation of the IDE Intergation packages depends on the IDE you use. For Visual Studio 2013, 2012 and 2010, the easiest way is to search for “SpecFlow” in the extension manager (Extensions and Updates in VS2013/VS2012) online search. For other IDE integrations and for the direct download links, check the Install IDE Integration page.

Setup SpecFlow Project

The SpecFlow tests are usually placed into one or more separate project in the solution: the “SpecFlow Projects”. The easiest and most convenient way to setup these projects is to use our NuGet package: SpecFlow or one of the specific helper packages, like SpecFlow.NUnit or SpecRun.SpecFlow. For a detailed project setup guide, check the Setup SpecFlow Projects page.

First Steps

This section guides you through the first steps of setting up a SpecFlow project and creating the first scenario. In the example, we use SpecFlow with NUnit, but you can choose from many other test execution frameworks, including SpecFlow+Runner that provides specialized execution features, Visual Studio Test Window and Team Foundation Server (TFS) Build integration for SpecFlow.

Have your first SpecFlow test running in just a few steps:

  1. Create a class library project: MyProject.Specs

    if you want to use SpecFlow with MsTest in VS2010, you should start with a “Unit Test Project”

  2. Add SpecFlow for NUnit through NuGet

    instead of NUnit you can also use other test engines, like MsTest, xUnit, MbUnit or SpecFlow+Runner

    PM> Install-Package SpecFlow.NUnit
  3. Add your first feature file

    we write yet-another StackOverflow clone now: SpecOverflow

    Add new feature file to the project
  4. Describe the first scenario of your application

    The first scenario
  5. Generate step definition skeletons

    Cool new feature in v1.9!

    Invoke step definition skeleton generation from the context menu
  6. Run your test – it is not green yet

    use your favorite test runner, like the VS2012 test runner below; but it works well with ReSharper too…

    Running the test produces inconclusive result
  7. Implement automation & application logic until the test is green

    The test finally passes
  8. Celebrate the good work and continue with the next scenario!

Want to learn more?

Explore the SpecFlow eco-system

Check out the products that make SpecFlow even more powerful

  • SpecFlow+ Runner (formerly known as SpecRun) – smarter integration test runner for SpecFlow
  • SpecFlow+ Excel – collaborate with business using Given/When/Then directly in Excel
  • SpecLog – living documentation system based on SpecFlow
  • Contact us if you want to be listed here!