Skip to content

Step names

Michael W Powell edited this page Dec 7, 2020 · 1 revision

Like Cucumber, xWellBehaved.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 the Arrange, Act, Assert pattern for organizing Unit Test code in methods.

"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 xWellBehaved.net with method and attribute names which are better suited to your chosen vocabulary.

Clone this wiki locally