https://github.com/swift-nav/rules_gherkin
A set of bazel rules for BDD with cucumber/gherkin
https://github.com/swift-nav/rules_gherkin
bazel bazel-rules cucumber cucumber-cpp
Last synced: 4 months ago
JSON representation
A set of bazel rules for BDD with cucumber/gherkin
- Host: GitHub
- URL: https://github.com/swift-nav/rules_gherkin
- Owner: swift-nav
- License: mit
- Created: 2021-01-13T07:20:38.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2026-01-27T15:30:04.000Z (5 months ago)
- Last Synced: 2026-01-28T02:13:01.453Z (5 months ago)
- Topics: bazel, bazel-rules, cucumber, cucumber-cpp
- Language: Starlark
- Homepage:
- Size: 71.3 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

 [](https://swift-nav.github.io/rules_gherkin/)
# rules_gherkin
A set of bazel rules for BDD with [cucumber/gherkin](https://cucumber.io/).
## Getting started
### Prerequisites
You'll need a `Gemfile` and `Gemfile.lock` in the root of your workspace with the following content:
```ruby
source 'https://rubygems.org'
gem 'cucumber', '~> 10.2.0'
gem 'cucumber-wire', '~> 8.0.0'
```
Run `bundle install` to generate the `Gemfile.lock` file.
### MODULE.bazel Setup
Add the following to your `MODULE.bazel` (see examples/MODULE.bazel for complete example):
```python
bazel_dep(name = "rules_gherkin", version = "0.1.0")
bazel_dep(name = "rules_ruby", version = "0.21.1")
ruby = use_extension("@rules_ruby//ruby:extensions.bzl", "ruby")
ruby.toolchain(
name = "ruby",
version = "jruby-9.4.5.0",
)
ruby.bundle_fetch(
name = "cucumber",
gem_checksums = { ... }, # See examples/MODULE.bazel for complete checksums
gemfile = "//:Gemfile",
gemfile_lock = "//:Gemfile.lock",
)
use_repo(ruby, "cucumber", "ruby", "ruby_toolchains")
register_toolchains("@ruby_toolchains//:all")
```
Note: The `gem_checksums` dictionary is required for hermetic builds. See `examples/MODULE.bazel` for the complete list of checksums.
### BUILD.bazel Example
Create a `BUILD.bazel` file in your feature directory:
```python
load("@rules_gherkin//gherkin:defs.bzl", "gherkin_library", "gherkin_test", "cc_gherkin_steps")
# Define your feature files
gherkin_library(
name = "feature_specs",
srcs = glob(["**/*.feature"]),
)
# Define step implementations in C++
cc_gherkin_steps(
name = "calculator_steps",
srcs = [
"CalculatorSteps.cpp",
],
visibility = ["//visibility:public"],
deps = [
"//Calc/src:calculator",
"@cucumber-cpp//:cucumber-cpp",
"@googletest//:gtest_main",
],
)
# Create test target
gherkin_test(
name = "calc_test",
steps = ":calculator_steps",
deps = [":feature_specs"],
)
```
## Configuration Options
### Output Format
You can configure the cucumber output format using the `--@rules_gherkin//:cucumber_format` flag:
```bash
bazel test //path/to:test --@rules_gherkin//:cucumber_format=json
```
Available formats:
- `pretty` (default) - Human-readable output
- `json` - JSON format
- `html` - HTML report
- `junit` - JUnit XML format
## Attribution
Big thank you to 'Paolo Ambrosio', who authored the [cucumber-cpp](https://github.com/cucumber/cucumber-cpp) from whom I copied and modified the //examples directory in this repository. The examples/LICENCE.txt has been added to reflect the origins of the example.