Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt AutoTest plugin and inherited tests

Qt AutoTest plugin and inherited tests

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
qtcreatorqt testqt autotest
2 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Resurr3ctionR Offline
    Resurr3ctionR Offline
    Resurr3ction
    wrote on last edited by
    #1

    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 to DerivedClassTest. 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!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      For Qt Creator plugins you should check the Qt Creator sources which are not part of Qt itself.

      As for Jira, it's here

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved