c++ - 运行 boost 测试项目时出错 : testcaseName: No such file or directory

标签 c++ boost boost-test boost-unit-test-framework

我正在尝试使用 boost 单元测试套件。

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE main_test_module

#include <boost/test/unit_test.hpp>
#include <boost/test/unit_test_suite.hpp>

.... // introducing some functions and variables here

BOOST_AUTO_TEST_CASE(fileComparatorTestCase)
{
Logger() << "Testing file comparator";

bool res;
res = compare(file1Path, file1Path);
BOOST_REQUIRE_EQUAL(res, true);
res = compare(file2Path, file2Path);
BOOST_REQUIRE_EQUAL(res, true);
res = compare(file1Path, file3Path);
BOOST_REQUIRE_EQUAL(res, false);
res = compare(file1Path, file2Path);
BOOST_REQUIRE_EQUAL(res, false);

Logger() << "Ended testing file comparator";
}

我还链接了 boost_unit_test_framework 库。此代码编译正常,但当我尝试运行测试运行器时,它失败并出现以下错误:

Running 1 test case...
unknown location(0): fatal error in "fileComparatorTestCase": std::exception: No such file or directory

关于如何修复它有什么想法吗?

最佳答案

显然,要么

  • Logger() 无法打开输出位置进行写入;
  • 您正在测试的compare 功能检查您传递的文件/路径是否存在。

尝试评论内容,直到找到罪魁祸首。如果异常是由 Boost 引起的,通常会提供更广泛的异常信息。否则,源代码或诸如 strace 之类的技巧可能会告诉您发生了什么。

关于c++ - 运行 boost 测试项目时出错 : testcaseName: No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22795731/

相关文章:

c++ - 从 vector 中删除一对并为 vector 对保留空间

c++ - Boost.Test 测试静态库

c++ - Boost Test 寄存器异常翻译器

xslt - 任何人都有将 Boost.Test XML 日志转换为可呈现格式的 XSL?

c++ - 在给定模板参数的模板类类型的类中声明变量

c++ - SQLite - 另存为?

c++ - 迭代器不能正常访问的问题

shell - bjam : Unable to load Boost. 构建:找不到 "boost-build.jam"

c++ - 尝试解析 Boost Spirit 语法时出现编译时错误

c++ - 清除 boost::array