Qt AutoTest plugin and inherited tests
-
I have recently started to use the experimental Qt AutoTest plugin in Qt Creator and I really like it. When designing hierarchy of classes I need to ensure that a subclass have not somehow broken the contract defined by the base class (and its test class). I found that easiest thing to do is creating a base class test and instead of using the tested class directly I use a method that returns smart pointer to it, e.g.:
class BaseClass { public: void foo(); }; class DerivedClass { public: void foo2(); };
And the test classes would be:
class BaseClassTest : public QObject { Q_OBJECT private slots: void foo_test(); protected: virtual std::unique_ptr<SomeClass> createSomeClass() const; }; class DerivedClassTest : public BaseClassTest { Q_OBJECT private slots: void foo2_test(); //void foo(); test is not visible to AutoTest plugin but it is executed just fine protected: virtual std::unique_ptr<SomeClass> createSomeClass() const override; };
This works fine and it saved me quite a few times already when I accidentally broken the base class' expected behaviour in the derived. Now the Qt AutoTest plugin picks up the test methods in
BaseClassTest
just fine but they do not propagate toDerivedClassTest
. I do not expect there to be a way to get them recognized in the current version of the plugin but I would like to suggest improvement (or write it myself) but I cannot find the current source for it or place to open an issue (Qt Jira bug-tracker?). Thanks for any advice!