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. Using QTest for GUI testing
QtWS25 Last Chance

Using QTest for GUI testing

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
qtestqtestlibgui testingmoc
2 Posts 1 Posters 1.9k 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.
  • K Offline
    K Offline
    koahnig
    wrote on last edited by
    #1

    I started to use QTest for GUI testing. At first I tested basically similar to any application some setters and getters for the widget to be tested. Since the widget shall be embedded into a dialog, I used a little test dialog for an event loop. This allows also to test some GUI stuff (changing in QComboBox, etc.).

    Finally I looked up the possibility to test out the gui with some keystrokes for a starter. The tutorial seems to be fairly easy to follow. I have added a routine testGui to my widget and call it through the Dialog used as noted above. The intensional introduced error in the testGui routine of the widget did not trigger anything.

    Therefore, I checked the tutorial and saw the need to include .moc file. As a starter I thought about including the widget moc file in addition to the tst.moc as it is typically with those test applications. However, I cannot find a generated .moc for my widget.
    Running qmake and rebuild all did not bring such a .moc (only the tst*.moc is present). Checking the compile output shows that the moc is not called for the widget, but the dialog and the widget as its content is working.

    I always thought the proper operation of moc is required for dialogs and widgets.

    Anyone has an explanation?

    Vote the answer(s) that helped you to solve your issue(s)

    K 1 Reply Last reply
    0
    • K koahnig

      I started to use QTest for GUI testing. At first I tested basically similar to any application some setters and getters for the widget to be tested. Since the widget shall be embedded into a dialog, I used a little test dialog for an event loop. This allows also to test some GUI stuff (changing in QComboBox, etc.).

      Finally I looked up the possibility to test out the gui with some keystrokes for a starter. The tutorial seems to be fairly easy to follow. I have added a routine testGui to my widget and call it through the Dialog used as noted above. The intensional introduced error in the testGui routine of the widget did not trigger anything.

      Therefore, I checked the tutorial and saw the need to include .moc file. As a starter I thought about including the widget moc file in addition to the tst.moc as it is typically with those test applications. However, I cannot find a generated .moc for my widget.
      Running qmake and rebuild all did not bring such a .moc (only the tst*.moc is present). Checking the compile output shows that the moc is not called for the widget, but the dialog and the widget as its content is working.

      I always thought the proper operation of moc is required for dialogs and widgets.

      Anyone has an explanation?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @koahnig

      Basically two problems on my side.

      .moc is not generated for every dialog as I thought. I got confused by name convention. moc_*.cpp are being produced.

      However, I had made another stupid error before. Accidently I had placed my test code into the contructor of the testing class and not in the routine testCase1() as required. However, since I had no problems from the being, I did not pay attention to this details. After moving the code to testCase1() also the test returns from my widget are monitored.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1

      • Login

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