Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Step names

Adam Ralph edited this page Jul 14, 2015 · 5 revisions

Like Cucumber, xBehave.net does not make any distinction between Given, When, Then, And and But steps.

"Given the number 1"
    .x(() => x = 1);

"And the number 2"
    .x(() => y = 2);

"And a calculator"
    .x(() => calculator = new Calculator());

"When I add the numbers together"
    .x(() => answer = calculator.Add(x, y));

"Then the answer is 3"
    .x(() => Assert.Equal(3, answer));

Instead of using Given, When, Then, you may choose to use another vocabulary, such as Arrange, Act, Assert (3A's)

"Arrange 1"
    .x(() => x = 1);

"Arrange 2"
    .x(() => y = 2);

"Arrange calculator"
    .x(() => calculator = new Calculator());

"Act"
    .x(() => answer = calculator.Add(x, y));

"Assert"
    .x(() => Assert.Equal(3, answer));

or xSpec style:

"Establish 1"
    .x(() => x = 1);

"Establish 2"
    .x(() => y = 2);

"Establish calculator"
    .x(() => calculator = new Calculator());

"Because I add the numbers together"
    .x(() => answer = calculator.Add(x, y));

"It answers 3"
    .x(() => Assert.Equal(3, answer));

You can even extend xBehave.net with method and attribute names which are better suited to your chosen vocabulary.

Clone this wiki locally