Questions tagged [qtestlib]

Qt Test is a framework for unit testing Qt based applications and libraries.

Qt Test provides functionality usually found in unit testing frameworks as well as extensions for testing GUI applications.

Qt Test is designed specially for Qt based applications and libraries.

Official documentation can be found here.

139 questions
2
votes
0 answers

How to use QTest to send a Ctrl-key combination in PyQt5?

I use PyQt5.6, Python 3.5 and Windows for a hobby project where I have an app with some actions (QAction) that have shortcuts set (for key combinations Ctrl-N and Ctrl-B, for example). I have written unit tests to verify that those actions can be…
Alex Tereshenkov
  • 3,340
  • 8
  • 36
  • 61
2
votes
0 answers

How to use Qtest to test a QT statemachine workflow

I'm trying to implement a QT state machine based workflow, and for testing purpose, I'm tring to play my workflow using QTest. void initTestCase() { machine = loadScxmlFile("StateMachine.scxml"); machine->start(); auto wrapper =…
Deswing
  • 21
  • 5
2
votes
1 answer

How to create integration test in QT?

How to create/launch integration test in QT? For example, I want to test my application on receiving events and check signals with QSignalSpy, but it looks like there is no option to execute your application and test after that. Update: I'm familiar…
htzfun
  • 1,231
  • 10
  • 41
2
votes
1 answer

QTest get test name

Within a Qt Unit-test, how can the program retrieve the name of the test being run? Code looks something like this: #include class MyTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase() { } void…
OJW
  • 4,514
  • 6
  • 40
  • 48
2
votes
1 answer

How can I test a full Qt5 GUI using qtestlib?

Using qtestlib with my Qt5 C++ widgets application, how can I test my full GUI? In the documentation for qtestlib, it is explained how I could test an indivdual QWidget by simulating keypresses etc, however this seems impossible to do for a full UI,…
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
2
votes
1 answer

QT Qtestlib, Unit Test

If I were to create a unit test for class implementation using QTestlib ( trying to figure it out) how would I do it. (I know unit testing for the simple class below can be done other simple way I trying to understand QTestlib framework and whether…
Sii
  • 661
  • 2
  • 7
  • 16
2
votes
2 answers

PyQt QTest click on QMenu

In my PyQt app I have a main menu, which has the following structure: Main Menu |___ | Language | | | Russian | | | English Exit I want to perform a click on Russian to test if the language…
GriMel
  • 2,272
  • 5
  • 22
  • 40
2
votes
1 answer

Force QBENCHMARK to perform several iterations

How can I perform several iterations using QBENCHMARK? For example I have this code: void MyUnitTest::speedText() { QBENCHMARK { obj->foo(); } } I looked at the documentation, and it says: The code inside the QBENCHMARK macro will…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
2
votes
1 answer

Qt Unit Test repeats everything twice in Qt Creator's Application Output pane for Qt 4.8 (but not in Qt 5.2.2)

I just noticed that even on a fresh new project, Qt Unit Test writes everything twice in the Application Output pane, in different colors - first in magenta, then in black. I assume this is because it writes to both stdout and stderr. This happens…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
2
votes
1 answer

Qtestlib: QNetworkRequest not executed

I would like to test an asynchronous request to a webserver. For that purpose I'm creating a simple unittest to quickly try a few lines of code: void AsynchronousCall::testGet() { QNetworkAccessManager *nam = new QNetworkAccessManager(this); …
dzen
  • 6,923
  • 5
  • 28
  • 31
2
votes
0 answers

PySide Asserts when preforming QTest.mouseClick on QTreeWidget

If I try to use QTest.mouseClick on a QTreeWidget it raises an assert from the C++ library. Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin from PySide import QtCore, QtGui from…
spikeynick
  • 499
  • 6
  • 12
2
votes
2 answers

QTest cannot pass events to child widgets

I'm writing some auto-test code using qtestlib. In the example code below: #include QWidget *win = new QWidget; QLabel *label = new QLabel("&what"); QLineEdit *le = new QLineEdit; label->setBuddy(le); QHBoxLayout *layout = new…
Yang Liu
  • 173
  • 2
  • 13
2
votes
1 answer

Help understanding QTest tutorials

In the tutorials for QTestLib, there are references to the files "testgui.moc" and "testqstring.moc" (one example can be found here:…
cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
2
votes
1 answer

QGraphicsItem selection with QTest::mousePress

I want to do some unit tests with qgraphicsitem. Below is simple code to test qgraphicsitem. QTest::mousePress(viewToTest->viewport(),Qt::LeftButton,Qt::NoModifier,viewToTest->mapFromScene(50,50)); QGraphicsItem *item =…
onurozcelik
  • 1,214
  • 3
  • 21
  • 44
1
vote
1 answer

How to resolve warning "ignoring return value of function declared with 'warn_unused_result' attribute"

I'm writing test automation in QT. I'am using QTest::qWaitFor to wait until the event loop switches to another tab in UI. QTest::qWaitFor([tabs, ¤tIdx]() {     currentIdx = tabs->currentIndex();     return currentIdx == 1; }, 5000); Each time…
Piotr Zych
  • 483
  • 4
  • 19