TinyBDD 0.10.1
dotnet add package TinyBDD --version 0.10.1
NuGet\Install-Package TinyBDD -Version 0.10.1
<PackageReference Include="TinyBDD" Version="0.10.1" />
<PackageVersion Include="TinyBDD" Version="0.10.1" />
<PackageReference Include="TinyBDD" />
paket add TinyBDD --version 0.10.1
#r "nuget: TinyBDD, 0.10.1"
#:package TinyBDD@0.10.1
#addin nuget:?package=TinyBDD&version=0.10.1
#tool nuget:?package=TinyBDD&version=0.10.1
TinyBDD
NuGet Packages:
| Package | Version | Downloads |
|---|---|---|
| TinyBDD | ||
| TinyBDD.MSTest | ||
| TinyBDD.Xunit | ||
| TinyBDD.NUnit |
TinyBDD is a minimal, fluent Behavior-Driven Development library for .NET.
It provides a lightweight Given / When / Then syntax with optional And / But chaining, supporting both sync and async steps.
It is designed to:
- Be framework-agnostic (works with MSTest, xUnit, NUnit, etc.).
- Keep scenarios clear and concise without heavy DSLs or external tooling.
- Support async and sync predicates for maximum flexibility.
- Integrate with existing test runners’ output for easy step visibility.
Features
Readable BDD syntax:
await Given("a number", () => 5) .When("doubled", x => x * 2) .Then(">= 10", v => v >= 10) .And("<= 20", v => v <= 20) .But("!= 15", v => v != 15) .AssertPassed();Sync & Async Support:
Func<T>/Func<T, bool>Func<Task<T>>/Func<T, Task<bool>>- Token-aware variants for advanced control.
And/Butchaining with correct step names in output:Given start [OK] When double [OK] Then >= 10 [OK] And <= 20 (async) [OK] But != 11 [OK]Test framework adapters:
- MSTest:
TinyBddMsTestBase,MSTestBddReporter,MSTestTraitBridge - xUnit:
TinyBddXunitBase,XunitTraitBridge,XunitBddReporter - NUnit:
TinyBddNUnitBase,NUnitTraitBridge,NUnitBddReporter - Automatically logs steps and tags to the test output.
- MSTest:
Installation
Add TinyBDD via NuGet:
dotnet add package TinyBDD
For MSTest:
dotnet add package TinyBDD.MSTest
For NUnit:
dotnet add package TinyBDD.NUnit
For xUnit:
dotnet add package TinyBDD.Xunit
Basic Usage
MSTest Example
using TinyBDD.MSTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
[Feature("Math")]
[TestClass]
public class MathTests : TinyBddMsTestBase
{
[Scenario("Doubling numbers")]
[TestMethod]
public async Task DoublingScenario()
{
await Given("start with 5", () => 5)
.When("doubled", x => x * 2)
.Then("should be 10", v => v == 10)
.AssertPassed();
}
}
NUnit Example
using TinyBDD.NUnit;
using NUnit.Framework;
[Feature("Math")]
public class MathTests : TinyBddNUnitBase
{
[Scenario("Doubling numbers")]
[Test]
public async Task DoublingScenario()
{
await Given("start with 5", () => 5)
.When("doubled", x => x * 2)
.Then("should be 10", v => v == 10)
.AssertPassed();
}
}
xUnit Example
using TinyBDD.Xunit;
using Xunit;
[Feature("Math")]
public class MathTests : TinyBddXunitBase
{
[Scenario("Doubling numbers")]
[Fact]
public async Task DoublingScenario()
{
await Given("start with 5", () => 5)
.When("doubled", x => x * 2)
.Then("should be 10", v => v == 10)
.AssertPassed();
}
}
Step Types
| Step | Purpose | Example |
|---|---|---|
Given |
Initial state / setup | .Given("start", () => 5) |
When |
Action / event | .When("doubled", x => x * 2) |
Then |
Assertion | .Then(">= 10", v => v >= 10) |
And |
Additional assertion after Then or When |
.And("<= 20", v => v <= 20) |
But |
Additional assertion phrased negatively | .But("!= 15", v => v != 15) |
All step types have sync and async overloads.
Tags
Tags can be added for reporting and filtering:
ctx.AddTag("smoke");
ctx.AddTag("fast");
In xUnit, tags are logged to the test output:
[TinyBDD] Tag: smoke
[TinyBDD] Tag: fast
Asserting Pass/Fail
TinyBDD tracks step results internally. At the end of the scenario, call one of the following methods:
Scenario.AssertPassed();
Scenario.AssertFailed();
// or use the fluent syntax:
await Given("one", () => 1)
.When("add one", x => x + 1)
.Then("equals two", v => v == 2)
.AssertPassed();
await Given("one", () => 1)
.When("add one", x => x + 1)
.Then("equals elevent", v => v == 11)
.AssertFailed();
This ensures that all steps passed and throws if any failed.
Philosophy
TinyBDD was created with a few guiding principles:
Focus on readability, not ceremony
Steps should read like plain English and map directly to Gherkin-style thinking, but without requiring.featurefiles, extra compilers, or DSL preprocessors.Code is the spec
Instead of writing a separate Gherkin text file, you write directly in C# using a fluent API that mirrorsGiven→When→Then→And→But.
Your unit test runner output is the human-readable spec.Stay out of your way
TinyBDD is not an opinionated test framework; it’s a syntax layer that integrates with MSTest, xUnit, or NUnit and leaves assertions, test discovery, and reporting to them.
Gherkin-Style Output
When running a scenario, TinyBDD prints structured step output similar to Gherkin formatting.
For example:
await Given("start", () => 5)
.When("double", x => x * 2)
.Then(">= 10", v => v >= 10)
.And("<= 20 (async)", v => Task.FromResult(v <= 20))
.But("!= 11", v => v != 11)
.AssertPassed();
Test output:
Feature: Math
Scenario: Doubling numbers
Given start [OK] 0 ms
When double [OK] 0 ms
Then >= 10 [OK] 0 ms
And <= 20 (async) [OK] 0 ms
But != 11 [OK] 0 ms
If a step fails, you’ll see exactly which step failed, how long it took, and the exception message.
Why Not Use SpecFlow / Cucumber?
SpecFlow, Cucumber, and similar tools are powerful for large-scale BDD, but they:
- Require separate
.featurefiles and a parser/runner. - Often introduce a disconnect between the feature file and the code that actually runs.
- Come with heavier setup and slower test discovery.
TinyBDD keeps everything in one place—your test class—while still producing clear, human-readable steps.
Minimal Example
For the smallest possible test:
await Given("one", () => 1)
.When("add one", x => x + 1)
.Then("equals two", v => v == 2)
.AssertPassed();
Output:
Given one [OK]
When add one [OK]
Then equals two [OK]
Async Philosophy
In TinyBDD, sync and async steps are equally first-class citizens.
If your step is synchronous, write it synchronously:
.When("double", x => x * 2) .Then("is 10", v => v == 10)If your step needs async work:
.When("fetch from DB", async x => await db.GetAsync(x)) .Then("result exists", async v => Assert.NotNull(v))
You can even mix sync and async steps freely in the same scenario.
Output Style
TinyBDD always prints the BDD keyword for the step type (Given, When, Then, And, But), the step title, the
result [OK] / [FAIL], and the elapsed time in milliseconds.
For failed steps, TinyBDD stops the scenario immediately and prints the exception:
Then equals two [FAIL] 1 ms
Expected: 2
Actual: 3
Recommended Usage
- One scenario per test method.
- Keep each step single-purpose—avoid hiding multiple unrelated actions in one step.
- Prefer creating functions, even local ones, to avoid unnecessary allocations, closure creation, garbage collection, and code cleanliness.
- Use
Scenario.AssertPassed()or the fluentThenChain.AssertPassed()at the end of each test to ensure every step was explicitly checked. - Use tags to group and filter tests.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 is compatible. net471 was computed. net472 is compatible. net48 is compatible. net481 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETFramework 4.7
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETFramework 4.7.2
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETFramework 4.8
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETFramework 4.8.1
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETStandard 2.0
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
.NETStandard 2.1
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (4)
Showing the top 4 NuGet packages that depend on TinyBDD:
| Package | Downloads |
|---|---|
|
TinyBDD.Xunit
TinyBDD is a minimal, fluent BDD library for .NET with Given/When/Then syntax, optional And/But chaining, and first-class sync/async support with adapters for MSTest, xUnit, and NUnit. |
|
|
TinyBDD.MSTest
TinyBDD is a minimal, fluent BDD library for .NET with Given/When/Then syntax, optional And/But chaining, and first-class sync/async support with adapters for MSTest, xUnit, and NUnit. |
|
|
TinyBDD.NUnit
TinyBDD is a minimal, fluent BDD library for .NET with Given/When/Then syntax, optional And/But chaining, and first-class sync/async support with adapters for MSTest, xUnit, and NUnit. |
|
|
TinyBDD.Xunit.v3
TinyBDD is a minimal, fluent BDD library for .NET with Given/When/Then syntax, optional And/But chaining, and first-class sync/async support with adapters for MSTest, xUnit, and NUnit. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.10.1 | 400 | 9/24/2025 |
| 0.10.0 | 399 | 9/17/2025 |
| 0.9.0 | 409 | 9/16/2025 |
| 0.8.3 | 254 | 9/13/2025 |
| 0.8.2 | 226 | 9/13/2025 |
| 0.8.1 | 288 | 9/10/2025 |
| 0.7.0 | 225 | 9/8/2025 |
| 0.6.1 | 233 | 9/7/2025 |
| 0.1.14 | 236 | 9/7/2025 |
| 0.1.13 | 225 | 9/4/2025 |
| 0.1.12 | 185 | 9/3/2025 |
| 0.1.11 | 180 | 9/2/2025 |
| 0.1.10 | 163 | 8/31/2025 |
| 0.1.9 | 167 | 8/31/2025 |
| 0.1.8 | 198 | 8/30/2025 |
| 0.1.7 | 219 | 8/28/2025 |