Excel Examples

The SpecFlow+ Excel plugin allows you to extend scenario outlines in plain text with Excel tables. Add the Excel files containing these test examples to your project so that the examples can be used by your executable tests. See SpecFlow+ Excel Getting Started for a quick introduction.

The sample feature file and the related Excel file include additional examples.

Using the Same Excel File to Describe Multiple Example Sets

One Excel examples file can be used to describe multiple example sets or even multiple scenario outlines. In this case, each worksheet should contain a single example set. In general, you should create an Excel examples file for each feature file. You can specify the name of the Excel sheet explicitly in the feature file, but this is not necessary if you name your sheets the same as your scenario outline titles. For more details, see Prepare Feature Files for External Examples.

Converting Excel Cell Values

Cell values, in particular non-string values like dates or numbers, are converted using a specific culture when executing tests. Cell formatting options in Excel (e.g. number of decimal places, rounding, currency signs, date formats) are ignored. See Converting Excel Cells for more details.

Prepare Feature Files for external Examples

In order to use SpecFlow+ Excel to extend your scenario outlines with additional examples, you need to extend the scenario outline examples blocks with a special @source tag as follows:


The excel-file-path is the path to the Excel file, relative to the feature file itself.

The sheet-name is optional. If no worksheet name is specified, the plugin uses the Excel sheet with the same name as the scenario outline, or the first worksheet in the file if there is no worksheet with a matching name.

The Examples block must contain a header row. The header row needs to match in both the feature file and the Excel file (same columns, same order).

You can also define concrete examples in the feature file. In this case, the examples from the Excel file are merged with the examples defined in the feature file. This sample feature file is extended with additional examples by this Excel file.

Feature: Calculator

Scenario Outline: Add two numbers
	Given I have entered <a> into the calculator 
	And I have entered <b> into the calculator 
	When I press add
	Then the result should be <result> on the screen 

	| case | a | b | result |