Skip to content

Gherkin Data Provider

Michael Altmann edited this page Sep 22, 2016 · 2 revisions

Description

This extension is a data provider for CherrySeed which defines and loads test data from Gherkin files.

Installation

Install Gherkin Data Provider via NuGet.

Defining Test Data

Test data can be defined with the beautiful Gherkin syntax which is known from SpecFlow or Cucumber. For each entity you have to call one Given sentence. Here is the content of the file TestData.feature:

Feature: TestData

Scenario: Adding test data
    Given the following data of entity 'Person'
    | Id   | Name    | Year       |
    | PE1  | Michael | 2016-01-01 |
    | PE2  | Julia   | 2016-02-01 |

    Given the following data of entity 'Project'
    | Id   | ProjectName     | Year       | Leader |
    | PR1  | Sell cars       | 2016-01-05 | PE1    |
    | PR2  | Increase budget | 2016-01-10 | PE2    |

The name of the file (=TestData.feature), the name of the feature (=TestData) and the name of the scenario (= Adding test data) are not relevant. It is up to you how you name it. You can also determine the Given sentence but it is a must that the entity name is between '. This entity name in the sentence have to match the class name of the entity. For more info see How to Have a Match?.

Configuration

This extension provide some configurations which can set via class GherkinDataProviderConfiguration:

Setting Name Description Default Value Example
FilePaths List of Gherkin file paths. Relative and absolute paths are supported. "C:\Temp\TestData.feature" or "./TestData.feature"

How To Use It

This code block initiates a Gherkin data provider and sets it globally in CherrySeed.

var gherkinDataProviderConfiguration = new GherkinDataProviderConfiguration() 
{
    FilePaths = new List<string> { "TestData.feature" }
};

var gherkinDataProvider = new GherkinDataProvider(gherkinDataProviderConfiguration);

var config = new CherrySeedConfiguration(cfg =>
{
    ...
    cfg.WithDataProvider(gherkinDataProvider);
    ...
});

Changelog

v1.0.0

  • Initial version
You can’t perform that action at this time.