Skip to main content

A small Gherkin DSL parser that generates stub code

Project description


Build Status


A small Gherkin DSL parser which reads in a feature file and produces stub code against a given test framework. This allows BDD to be integrated into new and existing projects without the need to depend on Cucumber.

The generated code is split into two files - the tests themselves and a set of scenario classes. This is to allow for:

  • easier version control of the source code
  • re-use of the scenario classes generation between unit test frameworks for the same language

The parser is written in Python and loads plug-ins for the desired output type.


A very basic test generator might look like

import cornichon

# Read the Gherkin DSL
f = open("example.feature", "r")
gherkin = f.readlines()

# Only need to call Settings for the test framework as it builds
# on those settings for the scenarios
settings = cornichon.Settings("cpp/cppunittest")
settings["rootnamespace"] = "Cornichon::"
settings["scenarios file"] = "example.h"

# Generate the tests
fp = open("example.cpp", "w")
fp.write(cornichon.Generate(gherkin, settings, "cpp/cppunittest"))

# Generate the test scenarios
fp = open("example.h", "w")
fp.write(cornichon.Generate(gherkin, settings, "cpp/cppscenarios"))

The values of the settings can be listed,


An explanation of those values can be printed,


The list of available output types can be printed,


Test frameworks


The scenario classes are generated using cpp/cppscenarios.

The supported frameworks are:

  • cpp/cppunittest - Microsoft's Visual C++ test framework
  • cpp/googletest - Google Test


The scenario classes are generated using cs/csscenarios.

The supported frameworks are:

  • cs/nunit - NUnit
  • cs/unittesting - Microsoft's Unit Testing framework


The scenario classes are generated using py/pyscenarios.

The supported frameworks are:

  • py/pytests - pytest, the pytest framework
  • py/pyunit_tests - unittest, the standard Python unit testing framework

Visual Basic

The scenario classes are generated using vb/vbscenarios.

The supported frameworks are:

  • vb/nunit - NUnit
  • vb/unittesting - Microsoft's Unit Testing framework


Contributions are welcome. Please read the testing documentation.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cornichon-0.9.6.tar.gz (11.9 kB view hashes)

Uploaded source

Built Distribution

cornichon-0.9.6-py3-none-any.whl (29.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page