Yet another BDD specification library for .NET
C#
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Penfold
TestDriven
Tests
.gitignore
LICENSE
Penfold.sln
README.md
appveyor.yml

README.md

penfold

Yet another BDD specification library for .NET

Build status NuGet version


Penfold can be installed from NuGet. Run the following commands from the Package Manager Console:

PM> Install-Package penfold

Penfold runs on NUnit so it should already work with your favourite test runner. Create a class that inherits from Specification then write your specification in the constructor:

[TestFixture]
public class CalculatorSpecification : Specification
{
    public CalculatorSpecification()
    {
        var calculator = new Calculator();

        before_each = () => calculator.Clear();

        describe["Addition"] = () =>
        {
            context["adding two and three"] = () =>
            {
                before = () => calculator.Key(2).Add(3);

                it["sets the total to five"] = () =>
                {
                    calculator.Total.ShouldEqual(5);
                };

                it["sets the history to:"] = () =>
                {
                    log(calculator.History.ShouldEqual("2 + 3"));
                };
            };
        };
    }
}

Penfold supports both RSpec style specifications and Gherkin:

[TestFixture]
public class CalculatorFeature : Specification
{
    public CalculatorFeature()
    {
        var calculator = new Calculator();

        comment = @"
            as a math idiot
            I want to use a calculator
            so I don't make mistakes with simple arithmetic
        ";

        Scenario["Addition"] = () =>
        {
            Given["I have pressed clear"] = () => calculator.Clear();
            When["I key in two"]          = () => calculator.Key(2);
            When["I add three"]           = () => calculator.Add(3);
            Then["the total is five"]     = () => calculator.Total.ShouldEqual(5);
            Then["the history is:"]       = () => log(calculator.History.ShouldEqual("2 + 3"));
        };
    }
}

Have fun 😀