c++ - How to use inheritance for a class with TEST_CLASS in CppUnitTestFramework -


i've got class inherits class so:

class testclass : public baseclass 

i wondering if possible make test class using test_class macro or other macro part of microsoft unit testing framework c++. tried:

class test_class(testclass : public baseclass) 

but ide gives error 'error: expected either definition or tag name' , compiler error error c3861: '__gettestclassinfo': identifier not found

i know it's bad practice inherit on test class make implementing test easier. relatively new c++ wondering if simple have missed or if it's not possible.

thanks,

there 1 other option didn't include , others may tripping on question without knowing solution.

you can derive arbitrary type looking @ macro itself:

/////////////////////////////////////////////////////////////////////////////////////////// // macro define test class.  // note can define test class @ namespace scope, // otherwise compiler raise error. #define test_class(classname) \ only_used_at_namespace_scope class classname : public ::microsoft::visualstudio::cppunittestframework::testclass<classname> 

as c++ supports multiple inheritance can derive using code similar following:

class parentclass { public:     parentclass();     virtual ~parentclass(); };  test_class(mytestclass), public parentclass { }; 

just remember if working resources need have virtual destructor have called. have call initialize & cleanup methods directly if going using them, because static methods create not called automagically.

good luck, testing!


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -