静态方法的 Gmock [英] Gmock for static methods

查看:63
本文介绍了静态方法的 Gmock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Gmock 进行测试.我有一个类,其中所有方法都是静态的.例如

I am using Gmock for testing.I got a class where all the methods are static. For Example

class A
{
  static int Method1(int x,int y){return (x+y)};
};

我如何使用 Gmock 测试这个类.请帮帮我.谢谢

How do I test this class using Gmock. Please help me out. Thanks

推荐答案

如果不修改代码,就无法做到.但是您可以将您的应用程序与存根对象链接起来.只需创建另一个A 类"实现并将其与您的测试应用程序链接即可.

You can't do it without modification of your code. But you can link your application with stubbed object. Just create another "class A" implementation and link it with your test application.

这篇关于静态方法的 Gmock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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