GoogleTest:通过测试访问环境 [英] GoogleTest: Accessing the Environment from a Test

查看:83
本文介绍了GoogleTest:通过测试访问环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试gtest for C ++(Google的单元测试框架),并且创建了:: testing :: Environment子类来初始化并跟踪大多数测试所需的一些内容(并且不要不想设置超过一次).

I'm trying out gtest for C++ (Google's unit testing framework), and I've created a ::testing::Environment subclass to initialize and keep track of some things that I need for most of my tests (and don't want to setup more than once).

我的问题是:如何实际访问环境对象的内容?我想从理论上讲我可以在测试项目中将环境保存到全局变量中,但是有更好的方法吗?

My question is: How do I actually access the contents of the Environment object? I guess I could theoretically save the Environment in a global variable in my test project, but is there a better way?

我正在尝试对一些已经存在(非常纠结)的东西进行测试,因此设置非常繁琐.

I'm trying to make tests for some already existing (very tangled) stuff, so the setup is pretty heavy.

推荐答案

根据 查看全文

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