0

During my first CTest (and CMake) project, I get for CTest the error

‘No tests were found!!!’

I added these four lines to CMakeLists.txt, just before the last install command inside CMakeLists.txt:

enable_testing()
add_executable(tester tester.cpp)
add_test(Tester tester)
target_link_libraries(tester PRIVATE ${PROJECT_NAME})

And I created in the main folder of the (Visual Studio CMake) project, a file tester.cpp.

Does anyone know how to fix it?

Michel Keijzers
  • 15,025
  • 28
  • 93
  • 119
  • 2
    Stupid question but: you didn't forget to re-run CMake after making the change? Should be automatic when you build the project but there's the occasional glitch. – Friedrich Feb 16 '23 at 09:31
  • 1
    @Friedrich I even cleaned up and rebuilt everything (a few times), without any difference. – Michel Keijzers Feb 16 '23 at 10:21

1 Answers1

0

The solution was to run the CTest command from the location where the test executable is stored.

By default the command line option from Visual Studio starts in the main folder of the project.

Michel Keijzers
  • 15,025
  • 28
  • 93
  • 119