Skip to the content.

bazel_cucumber

Rules Gherkin

A set of bazel rules for BDD with cucumber/gherkin.

NOTE: This is alpha level software, the API may change without notice

Getting started

Add the following to your WORKSPACE

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
    name = "rules_gherkin",
    commit = "COMMIT", # Update this to match latest commit
    remote = "https://github.com/silvergasp/rules_gherkin.git"
)
load("@rules_gherkin//:gherkin_deps.bzl","gherkin_deps")
gherkin_deps()

load("@rules_gherkin//:gherkin_workspace.bzl","gherkin_workspace")
gherkin_workspace()

Example BUILD file.

load("//gherkin:defs.bzl", "gherkin_library", "gherkin_test")

gherkin_library(
    name = "feature_specs",
    srcs = glob(["**/*.feature"]),
)

gherkin_test(
    name = "calc_test",
    steps = ":calculator_steps",
    deps = [":feature_specs"],
)

load("//gherkin:defs.bzl", "cc_gherkin_steps")

cc_gherkin_steps(
    name = "calculator_steps",
    srcs = [
        "CalculatorSteps.cpp",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//examples/Calc/src:calculator",
        "@cucumber_cpp//src:cucumber_main",
        "@gtest",
    ],
)


gherkin_library

gherkin_library(name, deps, srcs)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required  
deps A list of other gherkin_library scenarios to include List of labels optional []
srcs Gherkin feature specifications List of labels optional []

gherkin_test

gherkin_test(name, deps, steps)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required  
deps A list of gherkin_library definitions List of labels optional []
steps The steps implementation to test the gherkin features against Label optional None

cc_gherkin_steps

cc_gherkin_steps(attrs)

cc_gherkin_steps The steps implementation for a set of gherkin features

Wraps cc_binary with cucumber context https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary

PARAMETERS

Name Description Default Value
attrs Rule attributes none

Attribution

Big thank you to ‘Paolo Ambrosio’, who authored the 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.