Skip to content
A BDD/TDD framework based on xUnit .net and inspired by Gherkin.
C# Ruby Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Get it at NuGet.

What is it?

A BDD/TDD framework based on and inspired by Gherkin. Allows features and scenarios to be written directly in code rather than mapping to external feature files. Works seamlessly with tooling.

How do I use it?

public void PushingAnElementOntoAStack(int element, Stack<int> stack)
    "Given an element"
        .Given(() => element = 11);

    "And a stack"
        .And(() => stack = new Stack<int>());

    "When pushing the element onto the stack"
        .When(() => stack.Push(element));

    "Then the element should be at the top of the stack"
        .Then(() => stack.Peek().Should().Be(element));

The above example uses FluentAssertions to ensure outcomes but you don't have to use a fluent assertion library to use Any other method of assertion will also work just fine.

E.g. assertion

"Then the element should be at the top of the stack"
    .Then(() => Assert.Equal(element, target.Peek()));

You can also use fake/mock/test-double verification.

E.g. FakeItEasy verification

"Then a call to foo bar must have happened."
    .Then(() => A.CallTo(() => foo.Bar()).MustHaveHappened());

It's your choice. You can use any method of assertion, mocking and/or verification you like. Any framework which works with should work seamlessly with E.g. Moq, RhinoMocks, Shouldly, etc.


Our build server is kindly provided by CodeBetter and JetBrains.

YouTrack and TeamCity

How does it work? generates test commands. You can execute scenarios using any test runner. E.g. TestDriven.Net, Resharper, console/GUI, Visual Studio 2012 Test Runner, etc.

Each Given/When/Then/And/But step generates a separate test command. This makes it very easy to identify the exact point of failure in your test output. As soon as a step fails in a given scenario, all subsequent steps are not executed and are also marked as failures.

When you execute a scenario, passes default values for the parameters of the scenario. You can also provide example values for each of the parameters (see below).

If you have questions about using, either send a message to the project owners, raise an issue or come and chat to fellow users in the JabbR chat room.

Where can I get it? is available as a NuGet package. For update notifications, follow @adamralph.

Continuous integration builds are available at To build manually, clone or fork this repository and see 'How to build'.

What else does it do?


In addition to Given(Action body), When(Action body), Then(Action body) and And(Action body) as shown above.


(New in version 0.12.0) Marks a background method which will be run before each scenario


Provides example data for scenario methods which define parameters (similar to [InlineData])

But(Action body)

Can be used wherever it makes sense. E.g. "Given I am in the Sahara, When I look around, Then I see sand, But I don't see the sea".

More advanced


The Using() extension method registers an object for disposal after execution of all steps in the scenario. This is similar to the effect achieved with a C# using { } block. E.g. (within the body of a step) foo = new SomeDisposableType().Using();

step.Teardown(Action teardown)

A step where the teardown action is invoked after execution of all steps in the scenario. Use this overload when you want to perform teardown operations which are not encapsulated by disposable objects.


When added after a step definition, creates an isolated context containing a copy of all preceding steps plus the defined step. This is useful for mutating assertions, e.g. Stack.Pop(), followed by further assertions which rely on the un-mutated state.

step.Skip(string reason)

When added after a step definition, skips the defined step (similar to [Fact(Skip="...")]). This is useful for temporarily skipping assertions while the target is a work in progress.

Can I help to improve it and/or fix bugs?

Absolutely! Please feel free to raise issues, fork the source code, send pull requests, etc.

No pull request is too small. Even whitespace fixes are appreciated. Before you contribute anything make sure you read

CI builds are hosted at and are triggered after each commit to the default branch (including merging of pull requests).

Come and chat to fellow users and developers at the JabbR chat room.

What do the version numbers mean? uses Semantic Versioning. The current release is 0.x which means 'initial development'. Breaking changes are being kept to a minimum, since the library is already being piloted by a number of projects, so you are encouraged to start using right away. Certain parts of the API may be deprecated during initial development but, wherever practical, will not be removed before version 1.0 is released.

On which giant's shoulders does it stand? logo designed by Vanja Pakaski.

Something went wrong with that request. Please try again.