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
0
votes
1 answer

QTest covering paint method

I have custom QWidgets where all the painting is done manually (fillRect, drawRect, drawText, drawPixmap..) . There are up to 120 properties affecting what's going to be paint, how it's blinking and so on. Legacy spaghetti code. When I'm changing…
Libor Tomsik
  • 668
  • 7
  • 24
0
votes
0 answers

Qt5/QTest: How to mock the clock speed (QTimer, etc.)?

I'm looking for a way to vary (speed up) the clock for unit tests, so automated tests don't need to wait too long for time- or timer-dependent events to happen. Other frameworks sometimes provide e.g. "mock clocks", but I couldn't find anything…
jpw
  • 56
  • 3
0
votes
1 answer

Qt Model Test, removeRows

I have a tree model with internal structure similar to Simple Tree Model Example. There is a special array-type items, for which I want to display an index. My data method looks like this: QVariant Model::data(const QModelIndex & index, int role )…
UVV
  • 502
  • 8
  • 21
0
votes
0 answers

Running QTests from CLion

Is it possible to run all QTests from the CLion Test Runner? I have a CMake file that creates one target per Test Class, which ends up in several test targets that I can run one by one from CLion, but I haven't figured out how to run them all at…
Damir Porobic
  • 681
  • 1
  • 8
  • 21
0
votes
1 answer

QT QTest::keyclick or mouseMove seems don't work with QMenu in my case

I have a simple flow Click on QPushButton QMenu with a couple of actions appears Navigate through the QMenu using key clicks or mouse move. (Triggering actions from code isn't a way, it should be a clean GUI test). QTest::keyClick(m_menu,…
0
votes
1 answer

QTest execute tests in method instead of main

is there a way to execute QTest::qExec() in a classes method instead of a main()? I NEED to have my testproject compiled as a dll instead of a standalone .exe. The dll is used by an existing GUI, the test shall be executed by a button. When qexec is…
0
votes
0 answers

QT test fail on exception and continue next test rather than abort

I've had a look at some of the qtest source code and documentation and can't figure it out. Would like to run tests and have test cases fail if an exception is thrown, and then continue on to the next test. Is there a way short of recompiling qt…
codeMetis
  • 420
  • 4
  • 16
0
votes
1 answer

How to test private member functions of a class using QTestLib?

I am using QTestLib for Unit Testing and i ask myself how to test private member functions of my classes. I would like to build a test suite for an in-house shared library. What strategies do i have in Qt's context for this ? I thought that testing…
Fryz
  • 2,119
  • 2
  • 25
  • 45
0
votes
0 answers

How can I declare own methods in QTest test class?

Is it possible to declare a method in a QTest class (that extends QObject and uses the QOBJECT macro) which won't be executed by the framework, but can be used to bundle repeating routines? When I try to declare a void method inside this class, the…
0
votes
1 answer

Test method with Signals and Slots

I have the following two simple methods in a Qt Console Application: void Webservice::getFile(PostElement el) { parameter = ⪙ QUrl url(PATH); QUrlQuery query; query.addQueryItem(el.getParam(), el.getValue()); url.setQuery(query); …
Chu
  • 468
  • 1
  • 5
  • 21
0
votes
1 answer

qmake generated target_wrapper.sh fails on make check

I have a qmake project with a subdirs template and two child projects. The subdir projects are two testcases. The project is built with on mingw64. When I run "mingw32-make check", the process fails when the first testcase is called by the…
Jens Luedicke
  • 964
  • 2
  • 8
  • 20
0
votes
1 answer

How can I wait for a QWidget to close using QTestLib? [Qt5]

I am writing a QTest based test case for a class that derives from QWidget. After showing the widget, I want the test to end as soon as the widget is closed. My first attempt was to use QSignalSpy, only to find out that QWidget really does not send…
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
0
votes
1 answer

QTest : testing dialogs with sub dialogs

I am trying to create a test for a use case like this: A Dialog is opened Clicking on a button in this dialog opens a sub dialog Clicking on a button in the sub dialog closes it Some action is done in dialog after sub dialog has been closed I was…
Mickaël C. Guimarães
  • 1,020
  • 2
  • 14
  • 32
0
votes
4 answers

QCOMPARE of two floating-point infinity-values

QCOMPARE( std::numeric_limits::infinity(), std::numeric_limits::infinity()); fails with: Compared doubles are not the same (fuzzy compare) Actual (std::numeric_limits::infinity()): inf Expected…
AMA
  • 4,114
  • 18
  • 32
0
votes
1 answer

How to make a button press on a point (x, y) in QWidget

I am using QWebEngineView to make a web view to my project so first I add a widget in the UI form and promoted it to QWebEngineView it works fine now I want to make a button press inside this widget on a point x,y (which is a button inside the…
user7179690
  • 1,051
  • 3
  • 17
  • 40