Click here to Skip to main content
15,881,649 members
Articles / Programming Languages / C# 4.0

Introducing BDDfy: the simplest BDD framework for .Net

Rate me:
Please Sign up or sign in to vote.
4.96/5 (18 votes)
23 Sep 2013CPOL19 min read 51.4K   49  
This article is an introduction to installing and using bddify - a simple to use and extend BDD framework for .NET developers.
Bddify is a simple BDD framework for .Net developers.

If this is the first time you are using bddify you may want to check out some of the samples on NuGet. 
Just search NuGet for bddify and you will see a list of bddify samples. You may install one or more samples to see how the framework works.
Each sample installs required packages (including bddify, NUnit, RazorEngine and so on).

Bddify uses quite a few conventions to make it frictionless to use. For your convenience, I will try to provide a quick tutorial below:

##Finding steps
Bddify scans your bddified classes for steps. Currently it has two ways of finding a step: using attributes and using method name conventions.

Bddify runs your steps in the following order: SetupState, ConsecutiveSetupState, Transition, ConsecutiveTransition, Assertion, ConsecutiveAssertion and TearDown. 
Some of these steps are reported in the console and html reports and some of them are not. Please read below for further information.

###Attributes:
Bddify looks for a custom attribute called ExecutableAttribute on your method. To make it easier to use, ExecutableAttribute has a few subclasses that you can use:
You may apply Given, AndGiven, When, AndWhen, Then, and AndThen attributes on any method you want to make available to bddify.

###Method name matching:
bddify uses some conventions to find methods that should be turned into steps. Here is the current conventions. The method name:

 - ending with "Context" is considered as a setup method (not reported).
 - "Setup" is considered as as setup method  (not reported). 
 - starting with "Given" is considered as a setup method (reported). 
 - starting with "AndGiven" is considered as a setup method that runs after Context, Setup and Given steps (reported).
 - starting with "When" is considered as a transition method  (reported). 
 - starting with "AndWhen" is considered as a transition method that runs after When steps (reported).
 - starting with "Then" is considered as an asserting method (reported).
 - starting with "And" is considered as an asserting method (reported).
 - starting with "TearDown" is considered as a finally method which is run after all the other steps (not reported).

##Usage
All you need to do to bddify a class is to call 'this.Bddify();' from an executable path. This usually lives in a test method with only one line which is 'this.Bddify();'.
You may download some of the samples to see how bddify works.

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Genie solutions
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions