gtest和gmock之间有什么区别? [英] What is the difference between gtest and gmock?

查看:3953
本文介绍了gtest和gmock之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解 google-mock 测试。

我已经在 gtest

但我还是不能理解 gmock 为什么我们需要这个?

But still I could not able to understand what is gmock why do we need this?

gtest 用于单元测试。我们需要 gmock 然后,如果单元测试需要 gmock $ g>

gtest is used for unit testing. What for we need gmock then, if gmock is required for unit testing?

推荐答案

Google Mock不是测试框架本身,而是需要一个测试框架来编写测试。 Google Mock与Google Test无缝配合使用,它附带了Google Test捆绑的副本,从1.1.0开始,您还可以将其用于任何您选择的C ++测试框架。 - Google Mock,系统要求

"Google Mock is not a testing framework itself. Instead, it needs a testing framework for writing tests. Google Mock works seamlessly with Google Test. It comes with a copy of Google Test bundled. Starting with version 1.1.0, you can also use it with any C++ testing framework of your choice. " - Google Mock, System Requirements

Mock是像对象,通过提供受控行为来模拟真实交易的方式。例如,要测试股票行情应用程序,您可以创建一个假股票数据提供商,创建假股票行情来测试您的代码。想想单词mock,字面意思是模仿。

Mock are like objects, defined in such a way to mimick the real-deal by supplying controlled behavior. For instance, to test a stock tick application, you'd create a fake stock data provider that created fake stock quotes to test your code with. Think of the word mock, literally means 'to mimic'.

这篇关于gtest和gmock之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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