Catch2 Unit Tests - could not find env executable

81 views Asked by At

So I am currently writing a catch2 unit test for my c++ program and getting to know the basics of Unit tests, but I encountered the following problem with the following code(./tests being my executable for the tests:


cmake_minimum_required(VERSION 3.0)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(memory)

include_directories(
        ${CMAKE_SOURCE_DIR}/src
)
# Executable
add_executable(arrays
            src/main.cpp
)

# Fetch Catch2
Include(FetchContent)
FetchContent_Declare(
        Catch2
        GIT_REPOSITORY https://github.com/catchorg/Catch2.git
        GIT_TAG        v3.3.2
)
FetchContent_MakeAvailable(Catch2)

# Build Tests
enable_testing()
add_executable(tests
        src/arrays.test.cpp

)
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
target_include_directories(tests PRIVATE src/)

# Register Tests
add_test(tests env CTEST_OUTPUT_ON_FAILURE=1 ./tests)

I get the following error:

Unable to find executable: env Could not find executable env

I would be glad if someone could help me. Btw, I am coding on CLion

I already tried it with different parameters but no results sadly.

0

There are 0 answers