代码之家  ›  专栏  ›  技术社区  ›  Roman

运行boost测试项目时出错:testcaseName:没有这样的文件或目录

  •  0
  • Roman  · 技术社区  · 10 年前

    我正在尝试使用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
    

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

    1 回复  |  直到 10 年前
        1
  •  1
  •   sehe    10 年前

    显然,也是

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

    试着评论一些东西,直到找到罪魁祸首。如果异常源于Boost,通常可以获得更广泛的异常信息。否则,源代码,或者可能是诸如 strace 可以告诉你发生了什么。