Do you follow BDD?

Updated by Brady Stroud [SSW] 1 year ago. See history

123
<introEmbed body={<> In the old days, reading and understanding test cases was something only developers could do. Behavior-Driven Development (BDD) starts to solve this problem by enabling organizations to define their use cases in plain language and integrate these aspects with testing frameworks. </>} />

Using Gherkin syntax and a BDD framework like SpecFlow you can write test scenarios in plain language using a few key words (Given, When, Then). Plain language makes the test scenarios easy to understand, even for non-technical team members.

First think about the different scenarios that you want to test, then write them out in plain language using gherkin syntax.

Feature: Greeting Message Participant sees a greeting message

Scenario: Participant sees a greeting message Given I visit the website When I navigate to the greeting screen Then I see the greeting message

✅ Figure: Good example - Gherkin syntax scenarios (Given, When, Then)

Once you have your scenarios lined up, you should begin to write the test steps for each scenario.

[Given(@"I visit the website")]
public async Task VisitTheWebsite()
{
await HomePage.NavigateAsync();
}
[When(@"I navigate to the greeting screen")]
public async Task NavigateToWelcome()
{
await HomePage.NavigateToGreeting();
}
[Then(@"I see the greeting message")]
public async Task ThenISeeTheGreetingMessage()
{
var message = await HomePage.GetGreetingMessage();
Assert.IsTrue(message == GreetingMessage);
}

✅ Figure: Figure: Good example - Test steps to run, matching the Gherkin Syntax


Acknowledgements

Matt Goldman
Piers Sinclair
Jake Bayliss
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.