2 ms·
Years ago when I did .NET stuff, I had a framework that implemented Given, When, Then and And as properties on a 'Scenario' test superclass that just returned t
by thom 12y ago
Years ago when I did .NET stuff, I had a framework that implemented Given, When, Then and And as properties on a 'Scenario' test superclass that just returned this. I then created 'Steps' files that grouped relevant extension methods together with names describing a step in a BDD example. That allowed tests like these:
[Test]
public void ShouldDisplayBar()
{
Given.AFooWithId(1);
And.ABarWithText("Baz");
When.TheUserGoesTo("/food/show/1");
Then.TheyShouldSee("Baz");
}
The nice thing being you get nice intellisense and easy reusability and refactoring with the steps.
All that said, BDD isn't just changing the names of arrange, act and assert, it's more about coming up with a common language that lets you work as a team to describe examples of your system's behaviour. And the chances are, if you're just doing it one of these ways that is focused purely on code and syntax, you're not involving customers anyway.