Skip to content
msuarz edited this page Dec 4, 2010 · 4 revisions

Every Feature has three files: Feature, Runner and Steps

Feature

Describe the feature following Gherkin syntax with more flexibility.

Feature: greeter says hello
	In order to start learning BDD
	As a C# developer
	I want to write features in Visual Studio

Scenario: Say hello to Raconteur
	Given a greeter
	When I send it the greet message
	Then I should see "Hello Raconteur"

Runner

The feature becomes an xUnit runner.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Features 
{
    [TestClass]
    public partial class GreeterSaysHello 
    {
        [TestMethod]
        public void SayHelloToRaconteur()
        {         
            Given_a_greeter();        
            When_I_send_it_the_greet_message();        
            Then_I_should_see("Hello Raconteur");
        }
    }
}

Steps

The step definitions are a partial class of the Runner

namespace Features 
{
    public partial class GreeterSaysHello 
    {
        void Given_a_greeter()
        {
            ...
        }

        void When_I_send_it_the_greet_message()
        {
            ...
        }

        void Then_I_should_see(string Message)
        {
            ...
        }
    }
}
Clone this wiki locally