2014-04-01 23 views
0

我正在嘗試使用boost單元測試套件。運行boost測試項目時出錯:testcaseName:沒有這樣的文件或目錄

#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

很顯然,無論是

  • Logger()無法寫入打開輸出位置;
  • 您正在測試的compare函數檢查您傳遞的文件/路徑是否存在。

嘗試評論的東西,直到你找到罪魁禍首。如果Boost出現異常,通常可以使用更廣泛的異常信息。否則,源代碼或者諸如strace這樣的技巧可以告訴你發生了什麼。

+0

是的,我被我自己的異常系統欺騙了。 – Roman

相關問題