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
51
votes
11 answers

What unit-testing framework should I use for Qt?

I am just starting up a new project that needs some cross-platform GUI, and we have chosen Qt as the GUI-framework. We need a unit-testing framework, too. Until about a year ago we used an in-house developed unit-testing framework for C++-projects,…
Rasmus Faber
  • 48,631
  • 24
  • 141
  • 189
40
votes
4 answers

How to structure project while unit-testing Qt app by QTestLib

I got my Qt project and I'm using Qt Creator. I want to unit-test all my code. However I'm quite new at QTestLib framework but everyone recommended it for testing Qt-based source. Now I'm a little confused how to structure test project with app…
fifth
  • 4,249
  • 9
  • 45
  • 62
34
votes
2 answers

How do you get a widget's children in Qt?

I'm simulating keyPresses to an application through Qt's KeyPress function. All the KeyPresses work fine. However when I pass a QT::Key_Enter which is supposed to press the OK button of the currently active window, or QT::Key_Cancel for the cancel…
Owen
  • 4,063
  • 17
  • 58
  • 78
33
votes
2 answers

QT : get the class name of an object

I'm writing a test app that simulates key presses of another application. For every key press I have to check if the right window/form is shown. So what I do is get the pointer of the window being shown and get it's window title. However, not all…
Owen
  • 4,063
  • 17
  • 58
  • 78
17
votes
1 answer

How to run multiple QTest classes?

I have a subproject where I put all my QTest unit tests and build a stand-alone test application that runs the tests (i.e. I run it from within Qt Creator). I have multiple test classes that I can execute with qExec(). However I don't know what is…
DBedrenko
  • 4,871
  • 4
  • 38
  • 73
13
votes
2 answers

Unit Testing in QTestLib - running single test / tests in class / all tests

I'm just starting to use QTestLib. I have gone through the manual and tutorial. Although I understand how to create tests, I'm just not getting how to make those tests convenient to run. My unit test background is NUnit and MSTest. In those…
Dave Mateer
  • 17,608
  • 15
  • 96
  • 149
12
votes
1 answer

How can you edit a QTableView cell from a QTest unit test?

I'm writing a unit test for a custom Validator in a QTableView using the QTestLib framework. One of the most basic test cases could be described like this: Double click the table cell in the third column and the fourth row, and append the number…
Tim Meyer
  • 12,210
  • 8
  • 64
  • 97
11
votes
2 answers

Qt UI testing: How to simulate a click on a QMenuBar item using QTest?

I am trying to simulate a mouse click on a QMenu item from a QMenuBar, for example clicking on "Save As" QAction using the QTestLib framework. I am triyng this under Windows XP 32 bit and Qt 5.0.2. Any Ideas?
Popovici Silviu
  • 111
  • 1
  • 3
11
votes
2 answers

How to verify with QTest that an exception is thrown?

I'm stating in QT C++ world. I'm doing TDD using QTest class. I want to verify that in certain conditions an exception is thrown by my class under test. Using google test, I would use something like: EXPECT_THROW(A(NULL),…
Killrazor
  • 6,856
  • 15
  • 53
  • 69
10
votes
1 answer

Qt: How do I get the currently running window?

I'm writing a test app which simulates key presses and I would like to get what window is displayed after each key presses. Here's the code block. std::auto_ptr pForm(new MyForm(3,3)); QTest::keyPress(pForm.get(), Qt::Key_0); After…
Owen
  • 4,063
  • 17
  • 58
  • 78
10
votes
1 answer

Showing the result of QTestlib with Jenkins xUnit plug-in

I am trying to use Jenkins xUnit plug-in for my Qt unit test project, but I cannot make it work... Here is What I've done so far: First of all, I build my unit test project with qmakebuilder plug-in (providing the .pro to the qmakebuilder plug-in),…
mrz
  • 1,802
  • 2
  • 21
  • 32
9
votes
2 answers

Is it possible for QTestLib to display the GUI it is testing as it runs?

The use case is, I have a Qt app, and I would like to automate user-style testing of it; that is, I'd like to use keyClicks(), mouseClick(), and so on, but I would like for the Qt application window to actually be displayed while this is…
Roderick
  • 2,383
  • 3
  • 20
  • 33
8
votes
1 answer

Problems with QTest::mouseClick on QListWidget

I am trying to use QTest to do some testing. I have a QListWidget that I would like to click on to get a selection. But after the click, nothing is selected. Does anyone have any ideas? Here is my test class void TestGui::List() { TestDialog…
tim
  • 191
  • 5
7
votes
4 answers

How to compose all QtTestLib unit tests' results in a single file while using a single test project?

In our project we are using the QtTestLib for a unit testing. The reasons are that the whole project already uses Qt whenever it's possible and it's a GUI application, so we wanted to have ability for testing GUI interfaces. Our project is compiled…
Roman Kruglov
  • 3,375
  • 2
  • 40
  • 46
7
votes
3 answers

comparing QTest with other frameworks

Can you compare popular unit test frameworks for C++ with QTest of Qt? (cppunit, boost test, google test etc..) What are the advantages disadvantages? Thank you. note: GUI test is not very important for us.
trante
  • 33,518
  • 47
  • 192
  • 272
1
2 3
9 10