Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTest cleanupTestCase not calling (QueuedConnection) slot
Forum Update on Monday, May 27th 2025

QTest cleanupTestCase not calling (QueuedConnection) slot

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtestslot
2 Posts 2 Posters 264 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.
  • V Offline
    V Offline
    Vaquita Tim
    wrote on last edited by Vaquita Tim
    #1

    I am using QTest to test an application which uploads data to a SQL database. The application manages an independent thread for the classes involved in collecting the data and uploading them.

    In my test case, I instatiate a class to access the data and download it, to compare against the original values. This class is moved to the database thread managed by the application.

    After the tests have run, I want to DROP the database table. To do this, I need to invoke a slot in my test class which is running on the database thread.

    	QSignalSpy DropSpy( &m_DBConnector, &CDBConnector::TableDropped );
    	QVERIFY(DropSpy.isValid());
    	QMetaObject::invokeMethod( &m_DBConnector, "DropTable", Q_ARG(QString, CPerfusionDatabase::VariablesTable()) );
    	QVERIFY( DropSpy.wait(m_DBWait) );
    	QVERIFY( DropSpy.constLast().at(0).toBool() );
    
    

    However, it seems not to work when called from the cleanupTestCase function - the DropTable slot is not invoked (I place a breakpoint in DEBUG, and this is not hit).

    It does work if this code is invoked from a "regular" test slot.

    I presume that there is some kind of QTest/MOC magic which makes queuing a slot in another thread infeasible.

    Does anyone have any insight as to how to make this work ?

    [At present my best workaround idea is to run a DropTable test slot (within the test case exe being run), and try to ensure that this is the last test, but it doesn't sound very robust]

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

      Hi,

      Are you sure your database connection is still opened when arriving in the cleanup function ?

      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