如何运行gtest没有从谷歌日志记录
How to run gtests without logging from google log?
我正在用gtest运行单元测试。然而,我也使用谷歌博客在我正在测试的代码。不幸的是,这个输出妨碍了测试结果,看起来很混乱。我怎样才能去掉log输出呢?
这似乎有效,抑制所有日志消息。
int main(int argc, char * argv[]) {
FLAGS_logtostderr = true;
FLAGS_minloglevel = 5;
google::InitGoogleLogging(argv[0]);
// Start running unit tests here
}
从高级指南中,定义自己的空EventListener并超越所有调试日志,然后从事件侦听器中删除默认打印机。
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
// Gets hold of the event listener list.
::testing::TestEventListeners& listeners =
::testing::UnitTest::GetInstance()->listeners();
// Removes the default console output listener from the list so it will
// not receive events from Google Test and won't print any output. Since
// this operation transfers ownership of the listener to the caller we
// have to delete it as well.
delete listeners.Release(listeners.default_result_printer());
// Adds a listener to the end. Google Test takes the ownership.
// Basically you can define an empty class MinimalistPrinter
// derived from EmptyTestEventListener
listeners.Append(new MinimalistPrinter);
return RUN_ALL_TESTS();
}
示例程序在这里
相关文章:
- 奇怪的(对我来说)返回声明 - 在谷歌上找不到任何关于它的信息
- 谷歌测试中的期望值存储在哪里
- 谷歌模拟和覆盖关键字
- 如何使用ESP8266向谷歌主页发送命令
- 更正 CMakeList.txt 用于谷歌测试的文件?
- 如何将GTest与CMake一起使用?遵循谷歌指南时的链接问题
- 在没有 API 的情况下使用谷歌翻译文本
- 重载运算符<<采用谷歌 C++ 风格
- 如何在谷歌模拟中匹配 C 样式数组
- 如何让谷歌测试正常运行。测试总是失败。(它不会编译)
- 为什么我收到来自谷歌的错误请求?
- 如何使用不同的谷歌模拟运行相同的谷歌测试用例?
- 谷歌测试方法与流
- _mm256_load_ps调试模式下导致谷歌/基准测试的分段错误
- 谷歌测试:模板模板的笛卡尔乘积的类型列表与模板
- 如何通过谷歌博客将日志打印到一个文件中
- 是由互斥体包装的谷歌日志条目
- 将谷歌日志(glog)重定向到文件
- VLOG不适用于谷歌日志记录库(glog)
- 如何运行gtest没有从谷歌日志记录