BDD frameworks for .NET / C#
What BDD frameworks for .NET / C# are actively maintained? Let’s try some of them out!
What #BDD frameworks for #dotnet / #csharp are missing from @dwozn list at https://t.co/Ad1i9bU2Zs
— Henrik Lau Eriksson (@hlaueriksson) July 25, 2016
I will try actively maintained projects that:
- Is open source
- Is available on NuGet
- Has published a release this year
I group the frameworks into two categories:
- Behavior-driven development (BDD)
- Specifications written and read by developers.
- Specification by example (SBE)
- Specifications written and read by developers, testers and business analysts (Three Amigos).
Frameworks for Behavior-driven development:
Frameworks for Specification by example:
I’ll use ReSharper as my testrunner when it’s possible.
You can view the code at https://github.com/hlaueriksson/ConductOfCode
The subject
The stack, a last-in-first-out (LIFO) collection:
The specifications will test the behavior of:
- Empty vs nonempty stack
Peek()
andPop()
methodsInvalidOperationException
Now I will let the code speak for itself…
LightBDD
- Dependencies: NUnit | MbUnit | MsTest | xUnit
- NuGet: https://www.nuget.org/packages/LightBDD/
- Source: https://github.com/Suremaker/LightBDD
Console output during test execution:
View the commit on GitHub: 513f0fce52ce63073fe662f9a1279b879399d99d
HTML reports can be enabled with configuration:
Thanks Wojtek for the Pull Request
Machine.Specifications (MSpec)
- Dependencies: -
- NuGet: https://www.nuget.org/packages/Machine.Specifications/
- Source: https://github.com/machine/machine.specifications
View the commit on GitHub: 217e02c329bb8590e3aade6f5d0ff44d1ba14e6e
NSpec
- Dependencies: -
- NuGet: https://www.nuget.org/packages/nspec/
- Source: https://github.com/mattflo/nspec
Run the specs from the console:
.\packages\nspec.1.0.7\tools\NSpecRunner.exe .\ConductOfCode\bin\Debug\ConductOfCode.dll
View the commit on GitHub: dc8a8b5f65128a3a95920911cb0af60fdfd7c3a1
SpecsFor
- Dependencies: NUnit
- NuGet: https://www.nuget.org/packages/SpecsFor/
- Source: https://github.com/MattHoneycutt/SpecsFor
View the commit on GitHub: 96057b2d794d54dba98ed17c09ae26b3b91f37af
xBehave.net
- Dependencies: xUnit
- NuGet: https://www.nuget.org/packages/Xbehave/
- Source: https://github.com/xbehave/xbehave.net
View the commit on GitHub: a11c641a66d284d3ef508358e371475e4056a339
Concordion.NET
- Dependencies: NUnit
- NuGet: https://www.nuget.org/packages/Concordion.NET/
- Source: https://github.com/concordion/concordion.net
Why do I get the error “no specification extensions defined for: Concordion.NET.Internal.SpecificationConfig”?
Output is written to your temp folder:
C:\Users\<username>\AppData\Local\Temp\ConductOfCode\Concordion
View the commit on GitHub: 33631d54be3986b6263d7a22fd2888513a920ea6
SpecFlow
- Dependencies: NUnit | xUnit | MsTest
- NuGet: https://www.nuget.org/packages/SpecFlow/
- Source: https://github.com/techtalk/SpecFlow
View the commit on GitHub: 3c468931d7eb71e0fff2840200a25f67f5a0d273
Popularity
At the time of writing, based on the number of downloads from NuGet, the most popular frameworks are:
- SpecFlow
- Machine.Specifications (MSpec)
- SpecsFor
- NSpec
- xBehave.net
- LightBDD
- Concordion.NET