如何在Google C ++测试框架中发送自定义消息? [英] How to send custom message in Google C++ Testing Framework?

查看:182
本文介绍了如何在Google C ++测试框架中发送自定义消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Google C ++测试框架对我的代码进行单元测试。
我使用 Eclipse CDT with C ++单元测试模块进行输出分析。

I use Google C++ Testing Framework for unit testing of my code. I use Eclipse CDT with C++ Unit testing module for output analysis.

以前,我使用 CppUnit 它有宏系列 CPPUNIT*_MESSAGE ,可以这样调用:

Previously I used CppUnit it has macros family CPPUNIT*_MESSAGE that could be called like this:

CPPUNIT_ASSERT_EQUAL_MESSAGE("message",EXPECTED_VALUE,ACTUAL_VALUE)

是否可以在google测试输出中添加一些自定义文本?

Is there a way to include some custom text in google test output?

(最好是可以包含消息到现有程序读取的数据,用于使用google测试进行自动化单元测试。)

(Preferably the way that could include message to data that is read by existing programs for automated unit testing using google test.)

推荐答案

测试失败时,gtest宏返回一个用于输出诊断消息的流。

The gtest macros return a stream for outputting diagnostic messages when a test fails.

EXPECT_TRUE(false) << "diagnostic message";

这篇关于如何在Google C ++测试框架中发送自定义消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆