SpecFlow

Specification based testing is kind of testing I prefer. Once in a while I like to see what’s available. This time, it was SpecFlow framework. Based on Gherkin style specification, it creates your specs, nicely integrating with Visual Studio .NET (I used 2008). This is what an output of a test written with SpecFlow looks like in VS2008 (used R# 5 Beta 2 for as a test runner).

Given I have entered 50 and 70 into the calculator
-> done: CalculatorStepDefinition.GivenIHaveEntered50And70IntoTheCalculator() (0.0s)
When I press add
-> done: CalculatorStepDefinition.WhenIPressAdd() (0.0s)
Then the result should be 120 on the screen
-> done: CalculatorStepDefinition.ThenTheResultShouldBe120OnTheScreen() (0.0s)

1 passed, 0 failed, 0 skipped, took 1.75 seconds (NUnit 2.5.3).

(-> done lines are an ugly addition that looked like oimagethers didn’t have. Either it was the new R# or something else). In overall, it’s a nice attempt to bring pure specification, readable and meaningful into code. I didn’t like the fact that there were so many artifacts to manage around though. On top of that, refactoring scenarios is not the most pleasant thing in the world, as technically I had to regenerate CalculatorStepDefinition.cs file.

Currently, out of box, SpecFlow is coupled to NUnit, but this is probably something that is just matter of templates re-configuration. I like the attempt, though would not use it on a project that is entirely developed with TDD and is frequently reworked.

No Comments