【发布时间】:2013-11-01 22:40:05
【问题描述】:
我已经使用如下所示的代码启动并运行了 gtest。我想将测试输出打印到文本文件,而不是在控制台中显示。有没有办法做到这一点?
我从控制台使用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)? -
@crayzeewulf 是的!很好,谢谢。把它放在答案中并获得一些分数。这适用于任何程序还是与 gtest 相关?
-
RobotEyes,完成。此外,这种类型的 redirection 将适用于您在 shell 中运行的任何命令。
-
bash 和 cmake 独立:gtest_output option。 Windows,VS:选项
--gtest_output=xml和--gtest_output=xml:./与当前文件夹中的结果一起使用(我认为是解决方案之一)。
标签: c++ c bash cmake googletest