Skip to content

test: change test framework from cucumber-cpp to cwt-cucumber#89

Open
NeaguGeorgiana23 wants to merge 9 commits intomainfrom
cwt-cucumber
Open

test: change test framework from cucumber-cpp to cwt-cucumber#89
NeaguGeorgiana23 wants to merge 9 commits intomainfrom
cwt-cucumber

Conversation

@NeaguGeorgiana23
Copy link
Copy Markdown
Contributor

@NeaguGeorgiana23 NeaguGeorgiana23 commented Mar 13, 2026

This PR

  • Changes the test framework from cucumber-cpp to cwt-cucumber

Notes

We do this because cwt-cucumber is a lightweight, modern C++20 BDD testing framework for native C++ projects. We wanted to switch from cucumber-cpp because this framework was using a wire protocol and have Cucumber-Ruby connecting to a TCP port where the C++ implementation is listening.

Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
@NeaguGeorgiana23 NeaguGeorgiana23 requested review from a team as code owners March 13, 2026 11:42
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the project's testing infrastructure by migrating from the cucumber-cpp framework to cwt-cucumber. This change aims to leverage cwt-cucumber's benefits as a lightweight, modern C++20 BDD testing framework, eliminating the need for the cucumber-cpp wire protocol and its Ruby dependencies, thereby simplifying the test setup and execution.

Highlights

  • Test Framework Migration: Switched the C++ BDD testing framework from cucumber-cpp to cwt-cucumber.
  • Dependency Cleanup: Removed cucumber-cpp's wire protocol dependency and associated Ruby tooling and Bazel rules.
  • Modern C++20 Integration: Integrated cwt-cucumber as a lightweight, modern C++20 testing framework, simplifying test setup and execution.
Changelog
  • BUILD
    • Removed gherkin_library rule and replaced it with a filegroup for Gherkin feature files.
  • Gemfile
    • Removed the Gemfile, as Ruby dependencies are no longer needed.
  • Gemfile.lock
    • Removed the Gemfile.lock, reflecting the removal of Ruby dependencies.
  • MODULE.bazel
    • Removed cucumber-cpp, rules_gherkin, and rules_ruby dependencies, along with the Ruby toolchain and Bundler integration.
    • Added a new cwt_extension.bzl to fetch and integrate cwt-cucumber.
  • test/e2e/BUILD
    • Updated Bazel build rules by removing rules_gherkin and cucumber-cpp dependencies.
    • Changed the gherkin_test rule to a standard cc_test and added cwt-cucumber as a dependency.
  • test/e2e/context_storing_provider.cpp
    • Removed cucumber-cpp specific includes and ScenarioScope usage.
  • test/e2e/cwt_extension.bzl
    • Added a new Bazel module extension to define how cwt-cucumber is fetched and built from its GitHub repository.
  • test/e2e/steps/BUILD
    • Converted cc_gherkin_steps to cc_library, added C++20 compilation options, and updated the dependency from cucumber-cpp to cwt-cucumber.
  • test/e2e/steps/minimal_steps.cpp
    • Migrated Gherkin step definitions from cucumber-cpp syntax to cwt-cucumber syntax, including changes to includes, ScenarioScope replacement with cuke::context, and step definition macros.
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully migrates the testing framework from cucumber-cpp to cwt-cucumber, which is a great move towards a more modern and lightweight C++20 BDD framework. The changes involve removing the Ruby-based dependencies and build configurations, and replacing them with the new setup for cwt-cucumber. The updates to the Bazel build files and the C++ step definitions are consistent and correct. I have one suggestion to improve the maintainability and security of how the new cwt-cucumber dependency is fetched.

Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Comment on lines +11 to +39
#Inject a BUILD file to compile it on the fly
build_file_content = """
load("@rules_cc//cc:defs.bzl", "cc_library")

#Generate the version file from the template
genrule(
name = "generate_version_file",
srcs =["src/version.template"],
outs = ["src/version.hpp"],
cmd = "sed 's/@PROJECT_VERSION@/{version}/g' $< > $@",
)

cc_library(
name = "cwt-cucumber",
srcs = glob(
["src/**/*.cpp"],
exclude =["src/main.cpp"]
),
hdrs = glob([
"src/**/*.hpp",
]) +[
"src/version.hpp",
],
strip_include_prefix = "src",
copts =["-std=c++20"],
visibility = ["//visibility:public"],
)
""".replace("{version}", version),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think It should be moved into it's own file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdym exactly by this?

Copy link
Copy Markdown
Contributor Author

@NeaguGeorgiana23 NeaguGeorgiana23 Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

MODULE.bazel Outdated
Comment on lines +19 to +20
cwt_ext = use_extension("//test/e2e:cwt_extension.bzl", "cwt_ext")
use_repo(cwt_ext, "cwt_cucumber") No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on bazel, but on cpp-sdk-contrib I was using git_repository rule instead of writing my own extension. If we introduce it here, we have clear dependency definition and one place for specifing dependencies version. (currently you need to specify version of this library in cwt_extension.bzl). I checked that if we change those lines to:

git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

# Fetch cwt-cucumber directly from GitHub
git_repository(
    name = "cwt_cucumber",
    build_file = "//test/e2e:cwt-cucumber.BUILD",
    remote = "https://github.com/ThoSe1990/cwt-cucumber.git",
    tag = "2.8",
)

And create //test/e2e/cwt-cucumber.BUILD with contents:

load("@rules_cc//cc:defs.bzl", "cc_library")

# Generate the version file from the template by extracting the version from CMakeLists.txt
genrule(
    name = "generate_version_file",
    srcs = [
        "CMakeLists.txt",
        "src/version.template",
    ],
    outs = ["src/version.hpp"],
    cmd = """
        VERSION=$$(grep 'project(cwt-cucumber VERSION' $(location CMakeLists.txt) | sed 's/.*VERSION \\([0-9.]*\\).*/\\1/');
        sed "s/@PROJECT_VERSION@/$$VERSION/g" $(location src/version.template) > $@
    """,
)

cc_library(
    name = "cwt-cucumber",
    srcs = glob(
        ["src/**/*.cpp"],
        exclude = ["src/main.cpp"],
    ),
    hdrs = glob([
        "src/**/*.hpp",
    ]) + [
        "src/version.hpp",
    ],
    copts = ["-std=c++20"],
    strip_include_prefix = "src",
    visibility = ["//visibility:public"],
)

We get the same functionality, but in my opinion with clearer definition of dependencies and structure. Unfortunately, it makes the generation of version.hpp file a bit more complex, since we need to extract the info on version from the CMake file. @oxddr do you know what's the best practice here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

BUILD Outdated
Comment on lines 4 to 5
name = "openfeature_gherkin_spec_features",
srcs = glob(["spec/specification/assets/gherkin/evaluation.feature"]),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, are those files introduced with git submodule? I think @oxddr mentioned that It would be better to have single way of defining dependencies, and manage them by bazel. I needed to do something really similar with flagd-schemas in cpp-sdk-contrib. Is it something worth considering?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are introduced with submodule.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Since you moved handling this dependency to bazel, maybe we can remove the submodule?

Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Copy link
Copy Markdown
Contributor

@m-olko m-olko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wait for approval from @oxddr

BUILD Outdated
Comment on lines 4 to 5
name = "openfeature_gherkin_spec_features",
srcs = glob(["spec/specification/assets/gherkin/evaluation.feature"]),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: Since you moved handling this dependency to bazel, maybe we can remove the submodule?

NeaguGeorgiana23 and others added 2 commits March 26, 2026 08:13
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants