Of course, our favorite text editor Notepad++ gives us syntax highlighting. Although the installation comes with a great set of predefined languages, the gherkin format used for SpecFlow-/Cucumber feature files is not supported out of the box.
Luckily, it is possible to define the bits and pieces for custom languages. In this blog post, Jaco Swarts provides the complete XML file with the language definition for for the gherkin language.
Due to the mismatch of language features of Notepad++ and language constructs in gherkin, some things are not possible with syntax highlighting:
Tables and Comments
In Jaco’s language definition, tables are considered single line comments as this seems to be the only way to format tables nicely. But table headers cannot be treated differently as done in Visual Studio (see comparison below). As second consequence, real gherkin comments (prefaced by a hash mark – #) are not supported at all. But I think this was a good consideration since tables will be more vital on skimming over a feature file than comments are.
Gherkin supports multiline strings, delimited by triple quotes. Also this seems not to be possible with the language features of Notepad++.
See the following screenshot for a comparison of the different renderings:
Version for Feature Files in German
Since one major goal of BDD is to raise the bandwidth of the communication channel between all stakeholders of a project including the business/domain experts, it is vital to have feature files in the communication language of the project.
If you are using feature files in German, you want to take advantage of that language definition for Notepad++: http://dl.dropbox.com/u/9238896/gherkin_de.xml. The keywords in this file are taken from the language file of the SpecFlow project.
Issue with gherkin keyword “Funktionalität” (Feature)
Up to now, I did not manage to get Notepad++ to accept the keyword “Funktionalität” correctly. That seems to be the case because of the umlaut a. Although stated as XML entity and displayed properly in the language dialog, it is not rendered as the other keywords:
There seems to be a problem having both the English and the German version installed in parallel. Sometimes the highlighting worked fine, but sometimes event a manual language switch from German to English gherkin (language menu) did not work.
Any hints regarding that are appreciated!