Skip to content

ColinOrr/penfold

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 😀

About

Yet another BDD specification library for .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages