Boost 测试与 Google 测试框架
我是单元测试世界的新手,基本上我是 C++ 开发人员,在一个大型产品上工作了近 3 年,现在我决定对我的代码执行自动化单元测试。为此,我在互联网上做了很多研究,遇到了很多工具和框架,最终选择了以下两个: 1) Boost测试库 2) Google Test Framework for c++
现在我很困惑从这些框架中选择哪个。如果有人使用上述任何一种,请分享您的经验。
I am new to Unit Testing world, basically I am c++ developer working on a large product for almost 3 years, and now I've decided to perform automated unit testing of my code. For this I do lot of research on the internet and came across many tools and frameworks and finally chose the following two:
1) Boost Test Libraries
2) Google Test Framework for c++
Now I am confused as to which to choose from those. If someone uses any of the above then please share your experience.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
下面的帖子几乎可以回答您的问题
The below SO posts pretty much answer your questions
如果您已经在使用
Boost 库
,请坚持使用 Boost 测试库。它应该可以满足您的大部分日志记录要求。否则,建议使用 Google 测试。我在一个大型项目中使用过它,发现它更容易使用。最重要的是,在 GTEST 中更容易找到编译器错误消息; boost 使用模板。我从未使用这两个库编写过复杂的测试。对于简单的测试,其中任何一个都可以。虽然
google-test
会节省你一些编译时间。Boost-test 与 boost-log 确实是一个很好的组合。试试吧!
If you are already using
Boost libraries
, then stick to Boost Test Libs. It should take care of most of your logging requirements. Otherwise, Google-test is recommended. I've used it in a large project and found it easier to use. Most importantly compiler-error messages are easier to locate in GTEST; boost uses templates.I have never written complicated tests using either of these two libraries. For simple tests, any of them would do fine. Although
google-test
will save you some compile time.Boost-test with boost-log is really a good combination. Try it!
建议您看一下 googlemock,它是 googletest 的超集。 Googlemock 具有 googletest 的所有测试功能以及 googlemock 的模拟功能。
Suggest you take a look at googlemock, a superset of googletest. Googlemock has all the testing capabilities of googletest plus the mocking capabilities of googlemock.