如何使CPP单元灯运行? 我是C++的新手,C++的单元测试。我试着让CPPFUnit light运行,但到目前为止没有成功,实际上我现在不知道该怎么办。这是我的代码: #include <iostream> #include <string> #include "CppUnitLite/TestHarness.h" using namespace std; int main() { TestResult tr; TestRegistry::runAllTests(tr); return 0; } TEST( Stack, creation ) { CHECK_EQUAL("a", "a"); } #包括 #包括 #包括“CppUnitLite/TestHarness.h” 使用名称空间std; int main() { 测试结果tr; TestRegistry::runAllTests(tr); 返回0; } 测试(堆栈、创建) { 检查是否相等(“a”、“a”); }

如何使CPP单元灯运行? 我是C++的新手,C++的单元测试。我试着让CPPFUnit light运行,但到目前为止没有成功,实际上我现在不知道该怎么办。这是我的代码: #include <iostream> #include <string> #include "CppUnitLite/TestHarness.h" using namespace std; int main() { TestResult tr; TestRegistry::runAllTests(tr); return 0; } TEST( Stack, creation ) { CHECK_EQUAL("a", "a"); } #包括 #包括 #包括“CppUnitLite/TestHarness.h” 使用名称空间std; int main() { 测试结果tr; TestRegistry::runAllTests(tr); 返回0; } 测试(堆栈、创建) { 检查是否相等(“a”、“a”); },c++,unit-testing,cppunit,C++,Unit Testing,Cppunit,在代码块中,我收到以下错误消息: UnitTestTest/main.cpp | 10 |对TestResult的未定义引用::TestResult()| UnitTestTest/CppUnitLite/Test.h | 21 |对SimpleString的未定义引用::~SimpleString()| UnitTestTest/main.cpp | 17 |对Test::Test的未定义引用(SimpleString const&)| 为include包含2个dir很简单 project_d

在代码块中,我收到以下错误消息:

UnitTestTest/main.cpp | 10 |对TestResult的未定义引用::TestResult()| UnitTestTest/CppUnitLite/Test.h | 21 |对SimpleString的未定义引用::~SimpleString()| UnitTestTest/main.cpp | 17 |对Test::Test的未定义引用(SimpleString const&)|


为include包含2个dir很简单

project_dir (as it use include CppUnitLite/x.h)
project_dir/CppUnitLite (all header files including Simple Strings)
link to -lCppUnitLite
CppUnitLite与cppunit无关,标记错误 我添加了3个测试正常的Cmake文件

[gliang@www CppUnitLite]$ cat ../CppUnitLite/CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
enable_testing()
include_directories(
    ${CMAKE_SOURCE_DIR}/
    ${CMAKE_SOURCE_DIR}/CppUnitLite
)
link_directories(
    ${CMAKE_BINARY_DIR}
)
add_subdirectory(src)
add_subdirectory(test)
测试目录

[gliang@www CppUnitLite]$ cat ../CppUnitLite/test/CMakeLists.txt
set(test_SRCS
Stack.h
StackMain.cpp
StackTest.cpp
)
add_executable(cppunitLite ${test_SRCS})
target_link_libraries(cppunitLite CppUnitLite)
add_test(NAME cppunitLite COMMAND ${CMAKE_BINARY_DIR}/test/cppunitLite)
对于src(lib)dir

原始项目已数月未处于活动状态


请考虑其他备选方案

将-lcppunit添加到链接器。
[gliang@www CppUnitLite]$ cat ../CppUnitLite/src/CMakeLists.txt
set(lib_SRCS
Failure.cpp
SimpleString.cpp
Test.cpp
TestRegistry.cpp
TestResult.cpp
)
add_library(CppUnitLite ${lib_SRCS})