Gherkin Processor is a Python package that processes Gherkin files into Python dataclasses. It provides utilities for validating, processing, and saving Gherkin scenarios in both text and JSON formats.
- Gherkin scenario validation
- Gherkin scenario syntax issue description
- Gherkin scenario content processing into Python dataclass
- Save processed scenarios in text or JSON format
- Directly load scenarios from file paths
You can install the Gherkin Processor package by cloning the repository or downloading from the releases.
Requirements:
- Python 3.10+ version with pip installed
# 1. Clone the repository
git clone https://github.com/MarkLehoczky/gherkin-processor.git
# 2. Navigate to the cloned directory
cd gherkin-processor
# 3. Install the package via 'pip'
pip install .
# (Optional) 4. Set up pre-commit git hook
cp hooks/pre-commit.sh .git/hooks/pre-commit
- Go to the Releases page.
- Download the latest release.
- Extract the downloaded file.
- Navigate to the extracted directory.
- Install the package by clicking on the install file
- Windows file: "Install.bat"
- Linux file: "Install.sh"
The Gherkin Processor can be used via the command line interface (CLI).
gherkin-processor [-h] -i INPUT [-p] [-s] [--save-as-json] [--validate]
-h, --help show this help message and exit
-i INPUT, --input INPUT specify the input Gherkin file location to process
-p, --print print the processed Gherkin scenario to the standard output
-s, --save save the processed Gherkin scenario to a file
--save-as-json save the processed Gherkin scenario to a file in JSON format
--validate validate the input Gherkin file syntax
See the CLI examples for details.
The Gherkin Processor can also be used programmatically in a Python code.
from gherkin_processor.utils import scenario # file
from gherkin_processor.scenario import Scenario # class
# Load and process the scenario from a file
processed_scenario: Scenario = scenario.load("path/to/scenario.feature")
# Save the processed scenario to a file
scenario.save(processed_scenario, "path/to/saved_scenario.feature")
See the API examples and Data class structure for details.
This project is licensed under MIT License.