I am learning C++ and am working on a QT5 application which is going pretty well. I am at the point where I need to implement some unittests (catch2) on a few specific parts of the application.
I am lost... I know how to write the tests and there is quite alot of documentation about that. How to configure my project directory structure and the changes to make to CMakeList.txt is a very different story. It seems everyone sort of does whatever worked for them and then tries to not talk about it to much. 99% of all tutorials about testing start with creating the cpp files assuming everything else has already been taken care of and the left over 1% aren't really matching my requirements.
I am looking for some boiler-plate config or pointers on how to get this stuff to work. I myself came up with the following:
- project dir
- external
- linux
- Qt
- ArcGis
- src
- Gui
- Menus
- MainMenu.h
- MainMenu.cpp
- Views
- MapView.cpp
- MapView.h
- NavigatorView.cpp
- NavigatorView.h
- MainWindow.cpp
- MainWindow.h
- Menus
- Models
- BaseModel.h
- BaseModel.cpp
- SurveyModel.h
- SurveyModel.cpp
- SectionModel.h
- SectionModel.cpp
- StationModel.h
- StationModel.cpp
- DataSources
- Usb
- Reader.cpp <-- I want to build a test for this file
- Reader.h
- Usb
- main.cpp
- CMakeList.txt
- Gui
- tests
- DataSources
- Usb
- ReaderTest.cpp <-- where this would be the test file
- Usb
- CmakeList.txt
- DataSources
- linux
- CMakeList.txt
- global_config.h.in
- external
The CMakeList.txt for the ./src dir works and creates an executable for my application. But after that the confusion starts:
In the tests dir, I can build my tests aslong as I don't require anything from my src dir. Which make my tests rather useless. I tried include_dir and add_sub_directories and so on, but somehow I am doing something wrong.
The topLevel CMakeList.txt It would be cool if I could add different build targets in there, 1 to build the tests and one to build the application.
Is there anyone that can give me some pointers, maybe a git-repo with some boilerplate or something?