简体   繁体   English

使用CPPUNIT或GTEST进行VC ++ MFC应用程序的单元测试

[英]Unit testing VC++ MFC application using CPPUNIT or GTEST

I have a project developed in VC++ MFC. 我有一个用VC ++ MFC开发的项目。 every classs is extended by CObject class. 每个类都由CObject类扩展。 And the default constructors are not defined (may kept protected). 并且未定义默认构造函数(可以保持受保护的状态)。 I just want to unit test that application, while creating object i was finding runtime errors like Unhand-led exception access voilation at writing and reading locations error. 我只想对该应用程序进行单元测试,而在创建对象时我发现了运行时错误,例如在写入和读取位置时出现了Unhand-led异常访问错误。 Is it possible to test the application which is extending CObject class ??? 是否可以测试正在扩展CObject类的应用程序?

It's really not clear to me what is stopping you doing the testing without some examples (maybe you could invent a simple example to demonstrate your issue). 我真的不清楚是什么阻止了您进行测试而没有一些示例(也许您可以发明一个简单的示例来演示您的问题)。 If you want to access the protected class constructor you could do something like this. 如果要访问受保护的类构造函数,则可以执行以下操作。

class A
{
    protected:

    A() {}

    friend class TestClassA;
};

class TestClassA
{
    public:

    void TestA( void)
    {
        A a;
        // test a
    }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM