Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builds, but No tests were found #2914

Open
opmtk opened this issue Sep 27, 2024 · 0 comments
Open

builds, but No tests were found #2914

opmtk opened this issue Sep 27, 2024 · 0 comments

Comments

@opmtk
Copy link

opmtk commented Sep 27, 2024

Describe the bug

I started to write a simple test for my project, below of my top-level project. On the bottom of this top-level CmakeLists.txt, I do:

make_minimum_required(VERSION 3.28)
project(cool_app)
...
# Unit tests
add_subdirectory(test)

The test sub-dir contains the CMakeLists.txt:

cmake_minimum_required(VERSION 3.28)

set(PROJECT_UNIT_TESTS_NAME ${CMAKE_PROJECT_NAME}_unit_tests)
project(${PROJECT_UNIT_TESTS_NAME} LANGUAGES CXX VERSION 0.0.1)

find_package(Catch2 3 REQUIRED)

include(CTest)
include(Catch)

add_executable(${PROJECT_UNIT_TESTS_NAME} test1.cpp)
target_link_libraries(${PROJECT_UNIT_TESTS_NAME} PRIVATE Catch2::Catch2WithMain)

enable_testing()
catch_discover_tests(${PROJECT_UNIT_TESTS_NAME}
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build
)

After successfully build I want to run it:

$ ctest --test-dir ./build
Internal ctest changing into directory: /home/${USERNAME}/work/my_project/build
Test project /home/${USERNAME}/work/my_project/build
No tests were found!!!
$ ls -la build/test/cool_app_unit_tests
-rwxrwxr-x 1 ${USERNAME} ${USERNAME} 1133056 Sep 27 20:10 build/test/cool_app_unit_tests*

So, it exist but isn't found finally.

Expected behavior

running the test

Platform information:

  • OS: Ubuntu 24.04.1 LTS
  • Compiler+version: GCC 13
  • Catch version: *3.4.0-1build1 (Ubuntu shipped)

Additional context

I've checked the docs and Stackoverflow without success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant