简体   繁体   中英

Unit testing VC++ MFC application using CPPUNIT or GTEST

I have a project developed in VC++ MFC. every classs is extended by CObject class. 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. Is it possible to test the application which is extending CObject class ???

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
    }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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