Create a test folder:
Create a subfolder called tests in the main project.
In this folder, create a separate CMake file for the test.
Create a CMakeLists.txt file for the test:
In the tests folder, create a CMakeLists.txt file with the following contents:
Qt Code:
  1. cmake_minimum_required(VERSION 3.14)
  2.  
  3. project(CalculatriceTests)
  4.  
  5. find_package(Qt5 REQUIRED COMPONENTS Test)
  6.  
  7. add_executable(test_calculatrice
  8. test_calculatrice.cpp
  9. )
  10.  
  11. target_link_libraries(test_calculatrice Qt5::Test)
To copy to clipboard, switch view to plain text mode