Cucumber-CPP
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 the
CONTRIBUTING.md
file.
It relies on a few executables:
- cmake 3.1 or later. Required to setup environment and build software
It relies on a few libraries:
- Boost 1.46 or later (1.51+ on Windows). Required libraries: thread, system, regex, date_time and program_options. Optional library for Boost Test driver: test.
- GTest 1.6 or later. Optional for the GTest driver. By default downloaded and built by CMake.
- GMock 1.6 or later. Optional for the internal test suite. By default downloaded and built by CMake.
- Qt 4 or 5. Optional for the CalcQt example and QtTest driver (only Qt 5).
This header-only library is included in the source code:
It might work with earlier versions of the libraries, but it was not tested with them.
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:
# Download test suite
git submodule init
git submodule update
# Create build directory
cmake -E make_directory build
# Generate Makefiles
cmake -E chdir build cmake -DCUKE_ENABLE_EXAMPLES=on -DCMAKE_INSTALL_PREFIX=${prefix} ..
# Build cucumber-cpp and tests
cmake --build build
# Run unit tests
cmake --build build --target test
# Run install
cmake --build build --target install
# Check implementation against common cucumber test suite
cmake --build build --target features
Running the Calc example on Unix:
build/examples/Calc/BoostCalculatorSteps >/dev/null &
cucumber examples/Calc
Running the Calc example on Windows (NMake):
start build\examples\Calc\BoostCalculatorSteps.exe
cucumber examples\Calc
Getting started
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.