Skip to content

Getting Started

CraigRice edited this page Aug 22, 2023 · 7 revisions

Add the nuget package BddPipe:

https://www.nuget.org/packages/BddPipe/

Add the using statement:

using BddPipe;
using static BddPipe.Runner;

Basic example:

[Test]
public void Add_TwoPositiveNumbers_ValueIsCorrect()
{
  Scenario()
    .Given("two numbers", () => new { A = 5, B = 10 })
    .When("the numbers are summed", setup => setup.A + setup.B)
    .Then("sum should be as expected", result =>
    {
      Assert.AreEqual(15, result);
    })
    .Run();
}

Note: You can return anything from each step.

Important: Steps must end with a call to .Run() or .RunAsync() otherwise the result is not evaluated.

Output

Scenario: Add_TwoPositiveNumbers_ValueIsCorrect
  Given two numbers [Passed]
  When the numbers are summed [Passed]
  Then sum should be as expected [Passed]