이상하게도 테스트를 빌드하고 실행하면 정의 된 모든 테스트 (부스트의 BOOST_AUTO_TEST_CASE()
)가 각 cmake 정의 테스트 (cmake의 add_test()
)에서 실행됩니다. 나는 내가 구성에서 뭔가 잘못한 것이 틀림 없다고 확신하지만, 나 자신의 삶은 그것이 무엇인지 알아낼 수 없다.cmake test : 모든 테스트가 각 ctest에서 실행됩니다.
루트 CMakeLists.txt :
cmake_minimum_required(VERSION 2.8)
project("project")
-- some library findings and other configs --
enable_testing()
subdirs(test)
subdirs(src)
테스트 CMakeLists.txt :
add_test(NAME hash_structors COMMAND projectTest)
add_test(NAME hash_makeHash COMMAND projectTest)
add_test(NAME hash_tree_size_compare COMMAND projectTest)
add_test(NAME hash_tree_size_compare_random COMMAND projectTest)
add_test(NAME hash_tree_compare COMMAND projectTest)
add_test(NAME directory_manual COMMAND projectTest)
include_directories(../include)
add_executable(projectTest testMain.cpp
../src/hash.cpp
../src/hash_tree.cpp
../src/directory.cpp)
target_link_libraries(projectTest ${Boost_LIBRARIES}
${CRYPTO++_LIBRARIES})
testMain.cpp :
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE "project tests"
#include <boost/test/unit_test.hpp>
#include "test_hash.hpp"
#include "test_hash_tree.hpp"
#include "test_directory.hpp"
각 'test_NAME.hpp'는 다음과 유사한 테스트를 포함 이 :
#include "hash.hpp"
BOOST_AUTO_TEST_CASE(hash_structors)
{
Hash hash;
BOOST_CHECK_EQUAL("", hash.getHash());
}
BOOST_AUTO_TEST_CASE(hash_makeHash)
{
Hash hash = Hash("test");
BOOST_TEST_MESSAGE(hash.getHash());
// precomputed hash value for "test"
BOOST_CHECK_EQUAL("7ab383fc29d81f8d0d68e87c69bae5f1f18266d730c48b1d", hash.getHash());
}
감사합니다. 제대로 작동합니다. 그러나'projectTest -t hash_structors' ('* /'없이)를 써야했습니다. – alex