[CPP] Help to build my own project with Cucumber Cpp

115 views
Skip to first unread message

Félix

unread,
Mar 12, 2020, 6:02:31 AM3/12/20
to Cukes
Hi,

I followed all instructions in the documentation, I installed Cucumber-Cpp on Ubuntu and ran the examples.

Now I would like to use Cucumber for my own project, which will be a Qt application. So I created a very simple Qt Widget application, put my sources files in a "src" folder. In my project folder, I ran:

cucumber --init

Then I have my "cucumber.wire" file, I wrote my first feature in a .feature file, and in the "step_definitions" folder I implemented my feature steps into a .cpp file, inspired from CalculatorQtSteps.cpp.

What I have to do next ?

I am a CMake beginner, maybe there is something wrong in my understanding, but I understood cucumber cpp step definitions have to be compiled with CMake. So I took the CMakeList.txt file in the folder "cucumber-cpp/examples/CalcQt/CMakeLists.txt" and I tried to adjust this file by keeping the minimum code required. I got something like :

project(QtBdd)

if(TARGET Qt::Core AND TARGET Qt::Gui AND TARGET Qt::Widgets AND TARGET Qt::Test)
    add_library
(libqtbdd STATIC src/widget.cpp src/widget.h)
    set_target_properties
(libqtbdd PROPERTIES AUTOMOC ON)
    target_include_directories
(libqtbdd INTERFACE src)
    target_link_libraries
(libqtbdd
        PUBLIC
           
Qt::Core
           
Qt::Widgets
        PRIVATE
           
Qt::Gui
   
)

    add_executable
(QtTestQtBddSteps features/step_definitions/WidgetQtSteps)
    target_link_libraries
(QtTestQtBddSteps PRIVATE libqtbdd Qt::Test cucumber-cpp)

endif
()

My application is built with qmake, so I kept only one executable for the step definitions, and I use only QtTest, so I removed lines dealing with Boost and GTest.

As it is described in this documentation I ran the following commands to compile the step definitions :
cmake -E make_directory build
cmake
-E chdir build cmake ..
cmake
--build build
cmake
--build build --target test

On the last command I got "make: *** Aucune règle pour fabriquer la cible « test ». Arrêt." (sorry it is in french, but there is no rule to build target "test").
Some files are created in the build directory, but no executable "
QtTestQtBddSteps"

I think there is something I did not understand in the process, as I said, I am a CMake beginner, and I did not found any documentation about building cucumber cpp projects (on the Github, there is
"Detailed Documentation (to be done)"

Please, is anyone who can help me with the building process ? Even if it is by giving some guidelines, or documentation.

Regards
Reply all
Reply to author
Forward
0 new messages