Thursday, July 8, 2010

SpecFlow scenario outlines

As many people know, SpecFlow is a tool that allows to write test scenarios in a human readable form and then run them using NUnit (other testing frameworks are also possible).

So, scenarios for SpecFlow typically look like below(I use Calculator as the simplest sample):


Scenario: TC1 Add two numbers
Given I have entered 1 into the calculator
And I have entered 2 into the calculator
When I press add
Then the result should be 3 on the screen

Scenario: TC2 Add two numbers
Given I have entered 2 into the calculator
And I have entered 2 into the calculator
When I press add
Then the result should be 4 on the screen


Obviously, In many cases number of scenarios for a single feature will be more that two, and those scenarios may differ only by values that are set as parameters.
And scenario outlines allow to define a scenario outline and then set a table of all parameters that should be passed to individual scenarios. Thus, the scenarios above may be transformed into:


Scenario Outline: TC5
Given I have entered <x> into the calculator
And I have entered <y> into the calculator
When I press add
Then the result should be <result> on the screen

Scenarios: addition
| x | y | result|
| 1 | 2 | 3|
| 2 | 2 | 4|

The scenario outline provides the same as individual scenarios (it will be the same number of tests with the same output). Moreover, when SpecFlow steps (which are defined in C#) are set for individual scenarios, they may work for Scenario outlines with no modifications. For instance, to make scenario outline above working , I didn’t write any line of code, I just changed the SpecFlow scenarios in the text editor. Using similar approach most sets of repetitive tests may be transformed to Scenario outlines at any time when it's needed.

More details on Scenario outlines are available at:
scenario outlines

Friday, July 2, 2010

Notepad++ to recognize custom file extensions

As many others, I am using Notepad++ as an editor to modify many XML files, which may have different extensions than XML. Such files may be configuration files for ASP.NET or MSBuild files. By default, when I opened them in Notepad++, I saw no syntax highlighting, everything was just black and white. In order to turn the highlighting on, I needed to explicitly select XML as a language each time when I opened such files.

However, using the following link, I just set extensions to what I needed.

http://www.mattblodgett.com/2007/11/notepad-tip-syntax-highlighting-for.html

So I have those files immediately recognize as XMLs when I open them