【问题标题】:Error while running boost test project: testcaseName: No such file or directory运行boost测试项目时出错:testcaseName:没有这样的文件或目录
【发布时间】:2014-04-01 19:59:27
【问题描述】:

我正在尝试使用 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 库。这段代码编译得很好,但是当我尝试运行 testrunner 时,它失败并出现以下错误:

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

关于如何修复它的任何想法?

【问题讨论】:

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


    【解决方案1】:

    显然,要么

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

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

    【讨论】:

      猜你喜欢
      • 2010-12-18
      • 2016-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-11
      • 2014-01-03
      • 2021-11-18
      • 1970-01-01
      相关资源
      最近更新 更多