我有gtest和運行使用代碼如下所示。我想將測試輸出打印到文本文件中,而不是在控制檯中顯示。有沒有辦法做到這一點?如何將Google測試輸出打印到文本文件?
我使用控制檯中的cmake
運行測試:cmake CMakeLists.txt && make && ./runTests
。
#include "cw-test.c"
#include <stdio.h>
#include <gtest/gtest.h>
TEST(InputValidationTest, ValidateEntryLine)
{
...
}
...
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
這個工作適合你:'cmake CMakeLists.txt && make && ./runTests&> test_output.txt'(參見[this](http://code.google.com/p/googletest/wiki/) FAQ#The_Google_Test_output_is_buried_in_a_whole_bunch_of_log_message))? – crayzeewulf
@crayzeewulf是的!很好,謝謝。把它放在答案中,並得到一些觀點。它適用於任何程序還是與gtest有關? – RobotEyes
RobotEyes,完成。此外,該類型的[重定向](http://en.wikipedia.org/wiki/Redirection_(計算))將適用於您在shell中運行的任何命令。 – crayzeewulf