Questions tagged [qttest]

QtTest is a Qt module for unit testing Qt applications and libraries.

Documentation can be found here.

81 questions
3
votes
0 answers

Qt Unit Testing C++ with QML qtquick

I am trying to implement a Qt unit test and I would like to "click" a qtquick Button in QML from C++. I am successfully able to use QCompare on the properties of one of my QML objects in test_case3 but I can't figure out how to create a click event…
slayer
  • 643
  • 7
  • 14
3
votes
0 answers

QTest, mousePress and mouseMove: Drag-and-Drop events are missing in Qt tests

I have a GUI with QTreeView and QGraphicsSceneView. The model used by the tree view supports drag events and graphics scene supports drop events. I want to simulate user actions with QTest: mousePress, mouseMove, mouseRelease and so on. I write this…
Felix
  • 3,351
  • 6
  • 40
  • 68
3
votes
0 answers

How to pass multiple types into single QTest::addColumn call

I have a template function for serializing data to a file and another to retrieve it back using the ID returned by the fist function: template int serialize(const T &value); //returns id template T deserialize(int id); Now I…
Resurrection
  • 3,916
  • 2
  • 34
  • 56
3
votes
0 answers

Qt Test Simulated MouseEvent not forwared to child widget

I did some survey, if it might be possible to use QtTest to test some of my custom Qt Widgets. I was able to build and run tests and I was also able to simulate events and check them with QSignalSpy. The widgets I'm going to tests are not…
Aleph0
  • 5,816
  • 4
  • 29
  • 80
3
votes
1 answer

Qt Test command line options

I am very new to Qt and I am in the process of validating Qt Test unit testing framework. I am using Qt 5.5. I am able to create test cases using Qt macros and run them from Qt Creator but I am having issues when running from command prompt.…
medasumanth
  • 381
  • 4
  • 10
3
votes
1 answer

How to send a keyboard shortcut for a menu item with QTest?

In a unit test, I'm trying to send the keyboard shortcut Command+N (on Mac OS), which corresponds to a menu item in my app. I'm using the PySide.QtTest module. In the code below, I'm using QTest.keyClicks, which doesn't produce what I'm expecting.…
ptrico
  • 1,049
  • 7
  • 22
3
votes
1 answer

QtCreator subdirs project

I'm going to achieve the following hierarchy in my QtCreator project based on subdirs template: Project: subproject1 - static library subproject2 - static library subproject3 - unittests executable The only one executable will be in subproject3,…
Dejwi
  • 4,393
  • 12
  • 45
  • 74
2
votes
1 answer

Use QTest macros (QVERIFY, QCOMPARE, etc.) in function other than the test function

In general, the macros QVERIFY, QCOMPARE, etc. shall not be used outside a test function. The reason is, that in case of a failure, they interrupt the test with a return. If I want to do tests in a function, I should do them by hand and return false…
Thomas Klier
  • 449
  • 4
  • 16
2
votes
0 answers

How to simulate a QTest.mousePress event on a QListWidgetItem?

Forgive me if the question has already been asked, but I couldn't find the answer anywhere. I am trying to test a small gui that contains a QListWidget and a QTreeWidget. More specifically, I want to test the drag and drop behavior from one of the…
Martin
  • 105
  • 1
  • 10
2
votes
1 answer

QT Test using namespaces

I am using QT Test in QT5 and noticed none of the examples in their documentation (https://doc.qt.io/qt-5/qttestlib-tutorial1-example.html#writing-a-test) used a custom (non-QT) namespace, and really not even a QT namespace was referenced. I tried…
Yeet
  • 92
  • 7
2
votes
0 answers

Using superclasses in QT Tests

I'm trying to use a superclass to define common constructor, initTestCase(), cleanupTestCase(), init() and cleanup() code for tests. class BaseTest : public QObject { Q_OBJECT protected slots: void initTestCase(); void init(); void…
user182917
  • 1,688
  • 2
  • 14
  • 17
2
votes
1 answer

Using qExec to create Qt Test suite

QTest encourages you to organize unit tests as separate executables. There is special macro for this, that generates the main function: QTEST_MAIN. I found this approach not very clean, it is much more useful to run all tests at once. So i searched…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
2
votes
1 answer

How to control a QFileDialog using Qt Test?

I have 2 questions: How can I access a QFileDialog and write the path of a file in the "File name" field using the Qt Test module? I am asking that because I am developing some GUI tests in Qt and now I need to open a text file. The following code…
KelvinS
  • 2,870
  • 8
  • 34
  • 67
2
votes
0 answers

Detect segmentation fault in Qt unit test

Is it possible to detect segmentation faults (SIGSEGV) within the Qt test library? Within my testXXX() method, a segmentation fault is thrown which causes a core file to be written. The funny thing about that is that the QTest::qExec() method…
mefiX
  • 1,702
  • 3
  • 24
  • 39
2
votes
1 answer

Functional Test for QMessageBox... why does not work?

I would develop some functional tests for a pyqt application that uses PyQt (or PySide) as GUI library. The tests use Unittest and Qttest library, as reported in many resources, for example this stackoverflow question: Unit and functional testing a…
gunzapper
  • 457
  • 7
  • 19