This project demonstrates how to write tests for the Qt OPC UA library against the official Qt OPC UA test server using Cucumber-Cpp.
The file features/opcua.feature
contains the test scenarios written in Gherkin while features/step_definitions/CucumberCppQtOpcUaTestsSteps.cpp
implements the test context class and the step
definitions.
- Qt 6.x with the Qt OPC UA module installed
- Cucumber-Cpp (included as a submodule)
The dependencies of Cucumber-Cpp can be installed on Ubuntu 24.04 using the following command:
sudo apt install nlohmann-json3-dev libasio-dev libtclap-dev cucumber
The project is built using CMake.
The dependencies mentioned in the previous paragraph must be available in a place that is automatically searched by CMake or their path must be passed to CMake using the CMAKE_PREFIX_PATH
variable.
$ git submodule update --init
$ mkdir build
$ cd build
$ cmake ..
$ make
The Cucumber-Cpp framework acts as a server which knows about step definitions and listens for incoming connections from the Ruby based Cucumber implementation. The cucumber executable scans the scenario files written in Gherkin and instructs the server to run the scenarios step by step using its step definitions. For more details, see here.
Once the client has disconnected, the server executable exits.
$ export LD_LIBRARY_PATH=/path/to/Qt/6.x.x/gcc_64/lib # Optional, if the server requires it
$ export TEST_SERVER_PATH=/path/to/open62541-testserver
$ ./build/CucumberCppQtOpcUaTests &
$ cucumber
The cucumber
executable must be run from the directory where the features
directory is located
because the option to pass the path to the features directory seems to be broken at the moment.