Showing posts with label TRX2HTML. Show all posts
Showing posts with label TRX2HTML. Show all posts

Monday, 3 October 2011

SpecFlow BDD

You can add SpecFlow to your project using Nuget or you can download from:  http://specflow.org 

After using StoryQ in my previous post I thought I’d show the steps to produce the equivalent tests with SpecFlow.

Once you’ve installed SpecFlow to your machine and added the NUnit.Framework and SpecFlow dlls to your project you can create a SpecFlow Feature file:

image

The tests won’t pass yet because you need to bind the Step definitions to C# code:

image

Create a new C# class file and copy and paste the binding code above into it:

We now get running tests that have yet to be implemented:

image

So we can now fill in the implementation for each of the steps, adding in our BeforeScenario (setup) and AfterScenario (teardown) methods:

image

To download the source:

http://stevenhollidge.com/blog-source-code/BDD-REST-Demo.zip