Cucumber-Cpp allows Cucumber to support step definitions written in C++.
If you need to ask a question, don't open a ticket on GitHub! Please post your question on the Cucumber discussion group instead, prefixing the title with [CPP].
If you want to contribute code to the project, guidelines are in CONTRIBUTING.md.
It relies on a few executables:
- cmake 3.16 or later. Required to setup environment and build software
It relies on a few libraries:
- Asio 1.18.1 or later.
- Boost.Test 1.70. Optional for the Boost Test driver.
- GTest 1.11.0 or later. Optional for the GTest driver.
- GMock 1.11.0 or later. Optional for the internal test suite.
- nlohmann-json 3.10.5 or later.
- Qt6 or Qt5. Optional for the CalcQt example and QtTest driver.
- TCLAP 1.2.5 or later.
It might work with earlier versions of the libraries, but it was not tested with them. See the CI scripts for details about dependency installation.
Cucumber-Cpp uses the wire protocol at the moment, so you will need Cucumber-Ruby installed and available on the path. It is also needed to run the functional test suite.
Please mind that Cucumber-Cpp is not compatible with Cucumber-Ruby 3.x due to a bug in its wire protocol implementation.
To install the Ruby prerequisites:
gem install bundler // For windows: gem install bundle
bundle install
Building Cucumber-Cpp with tests and samples:
# Create build directory
cmake -E make_directory build
# Generate Makefiles
cmake -E chdir build cmake \
-DCUKE_ENABLE_BOOST_TEST=on \
-DCUKE_ENABLE_GTEST=on \
-DCUKE_ENABLE_QT_6=on \
-DCUKE_TESTS_UNIT=on \
-DCUKE_ENABLE_EXAMPLES=on \
..
# Build cucumber-cpp
cmake --build build
# Run unit tests
cmake --build build --target test
# Run install
cmake --install build
Running the Calc example on Unix:
build/examples/Calc/BoostCalculatorSteps >/dev/null &
(cd examples/Calc; cucumber)
Running the Calc example on Windows (NMake):
start build\examples\Calc\BoostCalculatorSteps.exe
cucumber examples\Calc
Here is a basic example on how to get started with cucumber-cpp. First you need to create the basic feature structure:
cucumber --init
Then create a cucumber.wire file in the features/step_definitions folder with the following content:
host: localhost
port: 3902
Create your first feature (an example is available here).
Then create your step definition runner (an example is available here). In order to compile the step definition runner, make sure to add cucumber include directory to the include path and link with libcucumber-cpp.a and additional testing libraries (boost unit test).
Run the step definition runner in the background and then cucumber, like in the Calc example in the previous section. The step definition runner should exit after the feature is run and cucumber exits.