Behavior-Driven Development (BDD) is an Agile approach that mixes requirement gathering, documentation and acceptance testing. You write human-readable sentences describing the features of your application and how they should work. Then you implement this behavior using a tool that produces automated acceptance tests to verify that the feature is implemented correctly. Open source .NET BDD tools like SpecFlow are used to store the requirements as live documentation and to perform functional or acceptance tests.
This article presents a list of open source software testing tools to perform Behavior-Driven Development (BDD) for the .NET platform and the C# language. For each tool, you will get a small description of its features. Feel free to suggest any additional .NET BDD framework or resource that you think should be included in this article. The tools, listed here are BDDfy, BDD toolkit for .NET, Concordion.NET, Kekiri, LightBDD, Machine.Specifications (Mspec), Nbehave, Nspec, Reqnroll, SpecFlow, SpecsFor, Storyteller, TickSpec, Xunit.Gherkin.Quick.
Updates
* December 2 2024
removed: xBehave.net (archived)
added: BDD toolkit for .NET, Kekiri, Reqnroll, Xunit.Gherkin.Quick
BDDfy
BDDfy is a simple open source .NET BDD framework that is easy to use, customize and extend. It can run with any testing framework and you can just apply it on your POCO (test) classes. BDDfy doesn’t need a separate test runner. You can use your runner of choice. For example, you can write your BDDfy tests using NUnit and run them using NUnit console. BDDfy is very extensible: the core barely has any logic in it and delegates all its responsibilities to the extensions, all of which are configurable.
Website: https://github.com/TestStack/TestStack.BDDfy
BDD toolkit for .NET
BDD toolkit for .NET is a lightweight .NET library for implementing BDD scenarios in pure C#. No enforcement of regular expressions. No strict conventions. Instead – close integration with C# syntax and maximum usage of its expressiveness. Thanks to that you can get instantly productive and focus on the domain you test.
BDD toolkit for .NET provides:
* Fluent syntax to write tests in Given – When – Then style
* Correct exceptions handling – all of assertions are checked even when an exception was thrown (more info here)
* Can be used with any test framework (xUnit, NUnit, MSTest)
* Generation of readable test scenarios directly from tests code (no semicolons, parentheses
Website: https://github.com/itlibrium/BDD-toolkit-dotnet
Concordion.NET
Concordion.NET is a small open source Behavior Driven Development (BDD) framework for C# and .NET that lets you turn plain English descriptions of requirements into automated tests. A Concordion.NET executable specification consists of two parts: a well-formed XHTML document describing the expected behavior, and fixture code written in C# (a special Concordion.NET extension of a NUnit tests) that finds concrete examples in the document and uses them to verify the system under test.
As the Concordion.NET framework focuses on business readable inputs, the specifications are are so readable, they can double up as system documentation. They are written in HTML, so can be easily hyperlinked into a navigable structure. With these automated acceptance testing, you can be confident the documentation is always up-to-date.
Website: https://github.com/concordion/concordion.net
Kekiri
Kekiri is an open source .NET framework that supports writing low-ceremony BDD tests using Gherkin language. Kekiri honors the conventions of the Gherkin cucumber language. Unlike other BDD frameworks that impose process overhead (management of feature files, custom tooling, etc) Kekiri allows developers to write BDD scenarios just as quickly and easily as they would a “plain old” test. The resulting scenario fixtures are concise, highly portable, and adhere to Act, Arrange, and Assert. IoC is also a first-class citizen encouraging testing object interactions in collaboration rather than isolation.
Website: https://github.com/chris-peterson/kekiri
LightBDD
LightBDD is an open source Behavior-Driven Development test framework that provides the ability to write tests that are easy to read, easy to track during execution and summarize the test results in user friendly report, while allowing developers to use all of the standard development tools to maintain them. LightBDD provides native support for refactoring, code analysis and test running. It has easy to read scenario definitions and scenario steps execution tracking and time measurement, usable during longer test execution.
LightBDD provides support for parameterized steps with smart rules of inserting argument values to formatted step name. It also supports contextual scenario execution where steps shares dedicated context. Results reports can be produced in XML, HTML or Plain text format. It integrates with NUnit, xUnit and MsTest.TestFramework frameworks and provides cross-platform support (.NET Framework / .NET Standard / .NET Core / UWP).
Website: https://github.com/LightBDD/LightBDD
MSpec / Machine.Specifications
MSpec or Machine.Specifications is a Context/Specification framework geared towards removing language noise and simplifying tests. MSpec is called a “context/specification” test framework because of the “grammar” that is used in describing and coding the tests or “specs”. To support readability and remove as much “noise” as possible, MSpec eschews the traditional attribute-on-method model of test construction. It instead uses custom .NET delegates.
Website: https://github.com/machine/machine.specifications
NBehave
NBehave is an open source framework for Behaviour-Driven Development (BDD) in ,NET. It was inspired by JBehave and runs on top of a ‘conventional’ Unit Testing framework like Nunit, mbunit, xunit and mstest.
Website: https://github.com/nbehave/NBehave
NSpec
NSpec is an open source testing framework for C# inspired by Mocha and RSpec. In NSpec, there is no need for access modifiers on tests, and no need to decorate test methods with attributes. It has some simple assertions, but you should really just use FluentAssertions, or Shouldly, or another assertion framework. You can build your own assertions by using extension methods. NSpec, as a member of the xSpec family, does not make use of attributes and instead obtains the same result with a set of expectations automatically created through code.
Website: http://nspec.org/
Reqnroll
Reqnroll is an open-source .NET test automation tool to practice Behavior Driven Development (BDD). Reqnroll is a .NET port of Cucumber and it is based on the SpecFlow framework and code base. You can find more information about the goal of the Reqnroll project and the motivations to create it on the Reqnroll website.
Reqnroll enables writing executable specifications for BDD using Gherkin, the widely-accepted feature file specification format. With that you can define the requirements using Given-When-Then style scenarios and turn them to automated tests in order to verify their implementation.
Reqnroll works on all major operating systems (Windows, Linux, macOS), on all commonly used .NET implementations (including .NET Framework 4.6.2+ and .NET 8.0). For executing the automated scenarios, Reqnroll can use MsTest, NUnit or xUnit. On Reqnroll projects you can work using Visual Studio 2022, Visual Studio Core and Rider, but you can also use Reqnroll without any IDE.
Website: https://reqnroll.net/, https://github.com/reqnroll
SpecFlow
SpecFlow is an open source .NET software testing tool that is part of the Cucumber family. It uses the official Gherkin parser and supports the .NET framework, Xamarin and Mono. You can use SpecFlow to define, manage and automatically execute human-readable acceptance tests in .NET projects. Writing easily understandable tests is a cornerstone of the BDD paradigm and also helps build up a living documentation of your system. SpecFlow integrates with Visual Studio, but can be also used from the command line (e.g. on a build server). SpecFlow supports popular testing frameworks: MSTest, NUnit, xUnit 2 and MbUnit.
Website: https://specflow.org/, https://github.com/SpecFlowOSS/
SpecsFor
SpecsFor is a lightweight open source Behavior-Driven Development testing framework for .NET that focuses on ease of use for developers by minimizing testing friction. It includes a base test fixture that automatically handles common testing concerns, packages to address common testing needs (such as mocking and fluent asserts), and helpers to easily overcome many testing hurdles. SpecsFor is flexible enough to support most approaches to testing. From “old-school” test methods to full-blown BDD-style specifications, SpecsFor helps you write tests the way you want to write them.
Website: https://github.com/MattHoneycutt/SpecsFor
Storyteller
Storyteller is an open source software testing tool to create robust, human readable acceptance tests for .NET or CoreCLR applications and a means to create “living” technical documentation. You can use Storyteller to create detailed executable specifications. Storyteller helps you create and easily maintain “living documentation” that can keep up with the pace of your development. No more excuses for missing documentation.
Website: https://storyteller.github.io/
TickSpec
TickSpec is a lightweight open source Behaviour-Driven Development (BDD) framework for .NET. You can describe behaviour in plain text using the Gherkin business language, i.e. Given, When, Then. With TickSpec you can easily execute the behavior against matching F# ‘ticked’ methods, or attribute-tagged C# or F# methods. You will run your tests using normal open source unit testing tools (xUnit, NUnit or standalone), set breakpoints in the scenarios and go.
Website: https://github.com/fsprojects/TickSpec
Xunit.Gherkin.Quick
Xunit.Gherkin.Quick is an open source cross platform BDD test framework (targets .NET Standard, can be used from both .NET and .NET Core test projects). It parses Gherkin language and executes Xunit tests corresponding to scenarios.
Key differences of Xunit.Gherkin.Quick from other BDD frameworks are:
- You write your expectations in a human-readable Gherkin language, not in code. This approach allows separation of concerns and responsibilities between requirement and code writing.
- Xunit.Gherkin.Quick is a lightweight framework. No auto-generated code that you fear to change; no Visual Studio dependency where the auto-generation works. With Xunit.Gherkin.Quick, you don’t even need an IDE (althought it works conveniently in Visual Studio) – one could write feature text files in a notepad, and code in any dev plugin; then run tests via .NET Core CLI.
- Supports full spectrum of Gherkin language idioms such as Given/When/Then/And/But/* keywords, Scenario Outlines, Scenario Backgrounds, and native Gherkin argument types (DocString, DataTable).
- All supported features are fully documented. Scroll down to the Documentation and Reference section after going through the Getting Started topic on this page.
Leave a Reply