Questions tagged [qttest]

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

Documentation can be found here.

81 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
31
votes
2 answers

Build Qt Tests with CMake

Can anyone give me an example of some QT test code and a CMakeLists.txt that build with Cmake and ran with CTest. I can't seem to find any! -Kurtis
Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102
15
votes
1 answer

Qt: run unit tests from multiple test classes and summarize the output from all of them

Qt comes with QTest, and there are some docs: for example, an official tutorial. However, QTest encourages you to organize unit tests as separate executables. There is special macro for this, that generates main(): QTEST_MAIN() To be honest, I…
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114
15
votes
2 answers

QtTest Unit Testing, how to add header files located in another project?

Maybe I'm missing something, but it seems really stupid to me that the only tutorial provided for QtTest framework has you testing the QString class. The typical use case for unit testing is....testing classes you wrote yourself, but there is no…
John Lotacs
  • 1,184
  • 4
  • 20
  • 34
12
votes
1 answer

Unit testing for Qt Quick

I am very new to Qt and Qt Quick. I am validating the Qt Test unit testing framework for Qt Quick and I am not able to understand how to run the tests. Here's what I have, I have created a SUBDIRS project with the following…
medasumanth
  • 381
  • 4
  • 10
12
votes
4 answers

Testing with Qt's QTestLib module

I started writing some tests with Qt's unit testing system. How do you usually organize the tests? It is one test class per one module class, or do you test the whole module with a single test class? Qt docs suggest to follow the former strategy. I…
ak.
  • 3,329
  • 3
  • 38
  • 50
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
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
1 answer

How to create a Qt-Quick Test

I have to create a Unit-Test. But first, I´ve to get clear what to do. There is a QtQuick2-App written and now I would like to do Unit-Tests with the GUI. What are the steps for Unit-Tests with GUI? After reading the Qt-documents, I could not create…
RefMa77
  • 283
  • 2
  • 14
6
votes
2 answers

Qt "monkey" Testing - simulate random clicks and keypresses

Is there a framework to simulate a deterministically pseudorandom series of clicks imposed upon a Qt application - in order to try to trigger any memory leaks, threading errors etc - typical monkey-testing? Some exotic, monkey use for QTestLib?
qdot
  • 6,195
  • 5
  • 44
  • 95
5
votes
3 answers

Unit testing (non-Qt) C++ code in Qt Creator?

I have a C++ project that doesn't use Qt. I am using Qt Creator as my IDE because it is very convenient. I was reading about unit testing in Qt Creator here, and I think that Qt Test seems quite good. Is there a way to use Qt Test with my non-Qt C++…
a06e
  • 18,594
  • 33
  • 93
  • 169
5
votes
4 answers

How to run qtestlib unit tests from QtCreator

I am developing a GUI application in Qt Creator and want to write some unit tests for it. I followed This guide to make some unit tests with QtTestlib and the program compiles fine. But how do I run them? I would like them to be run before the GUI…
Viesturs
  • 1,691
  • 4
  • 21
  • 25
4
votes
0 answers

QML test fails in Qt 5.9.1

While compiling in Qt 5.9.1 version it is not working.. Any one help me to compile this TestCase in qml.. import QtQuick 2.0 import QtTest 1.1 TestCase{ function test_math() { compare(2 + 2, 4, "2 + 2 = 4") …
Senthil Kumar
  • 562
  • 1
  • 6
  • 14
3
votes
1 answer

How can I immediately fail an auto test if a warning occurs

I want to instantly fail any auto test when a warning is printed in the tested code, so that I don't miss it in the output and end up with strange test failures later on. I thought I could use qInstallMessageHandler() for this. I modified the…
Mitch
  • 23,716
  • 9
  • 83
  • 122
1
2 3 4 5 6