Skip to main content

Write the test.
Read the report.

BDTest is a behaviour-driven testing framework for .NET with no Gherkin files and no generated tests. Your Given / When / Then scenarios are ordinary C#, and their results become reports your whole team can read.

Get starteddotnet add package TUnit dotnet add package BDTest.TUnit
Story

As an account holder, I want to withdraw money, so that I can use my savings.

PassedWithdrawing money reduces the balance
  1. GivenI have an account with a balance of 100
  2. WhenI withdraw 25
  3. Thenthe account balance is 75

Steps are methods. Scenarios are tests.​

Use your test runner, your IDE and your debugger as usual. The bundled source generator records which method each step calls. BDTest then reads the attributes and current argument values just before each step runs, and writes them into the report.

WithdrawalTests.cs
[Story(AsA = "account holder",
IWant = "to withdraw money",
SoThat = "I can use my savings")]
public class WithdrawalTests : TUnitBDTestBase<AccountContext>
{
private AccountSteps Account => new(Context);

[Test]
[ScenarioText("Withdrawing money reduces the balance")]
public async Task WithdrawMoney()
{
await Given(() => Account.CreateAnAccount(100m))
.When(() => Account.Withdraw(25m))
.Then(() => Account.TheBalanceIs(75m))
.BDTestAsync();
}
}
AccountSteps.cs
public class AccountSteps(AccountContext context)
{
[StepText("I have an account with a balance of {0}")]
public void CreateAnAccount(decimal balance) =>
context.Balance = balance;

[StepText("I withdraw {0}")]
public void Withdraw(decimal amount) =>
context.Balance -= amount;

[StepText("the account balance is {0}")]
public async Task TheBalanceIs(decimal expected) =>
await Assert.That(context.Balance).IsEqualTo(expected);
}

A code-first alternative to SpecFlow​

  • No Gherkin, no generated tests

    Steps are C# methods. Go to definition, refactor and set breakpoints as you would in any other code.

  • Rich arguments

    Pass enums, models and collections into steps. Step text formats them, and you can register custom converters.

  • Isolated by default

    Each test gets its own Context object, so scenarios run in parallel without shared state.

  • Any runner

    Adapters for TUnit, NUnit, xUnit and MSTest, or run standalone with BDTestBuilder.

  • Readable reports

    Stories, scenarios, steps, output and exceptions in one HTML file or on a shared report server.

  • Built for real suites

    Scenario outlines, tags, timeouts, retries, step hooks and skip rules.

Share a link, not a log file.​

Host the BDTest report server in any ASP.NET Core app. Test runs upload their results, and you get a URL to send to your team. Compare runs, spot flaky tests and follow trends over time.

BDTest report server showing a list of test runs with pass and fail counts