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
1
vote
1 answer

QTest mouseClick on a QPushButton

i tried to click a QPushButton with the mouseClick function of the QTest namespace. The QPushButton is a private Member of an Widget. The position of the mouse cursor during the click is in the center of the button, but the Button is not clicked...…
Andreas
  • 636
  • 1
  • 12
  • 29
1
vote
1 answer

Simple qtest fails with 'multiple definition of main'

This is the first time I'm making a test and i decided to try it in Qt since i'm on a Qt project now. What i tried to make is basically a "hello world" of a unit test so i can get familiar with Qt tests. The problem however is that compiling the…
Ferrilata
  • 13
  • 1
  • 3
1
vote
1 answer

How to use foreach loop on a QSignalSpy

How do I use a foreach loop on a QSignalSpy? This is what I want to do: foreach( const QList &args, mySignalSpy ) { Q_ASSERT( args.count() == 2 ); QVariant arg0 = args[0]; QVariant arg1 = args[1]; doSomething( arg0, arg1…
Freedom_Ben
  • 11,247
  • 10
  • 69
  • 89
1
vote
1 answer

error Using QTest Macro QCOMPARE

I want use QTest Macro QCOMPARE in my code,but I receive errors. QTestString.h #ifndef QTESTSTRING_H #define QTESTSTRING_H #include #include class TestqstringTest : public QObject { Q_OBJECT public: …
choujayyl
  • 91
  • 1
  • 4
  • 12
1
vote
3 answers

Qt test-unit: Error: undefined reference to `imp__ZN5Q

I am trying to create a "Qt unit test" following this tutorial. I created a new project: Qt Gui Application with a header file as mentioned and a class that contains the test function. I added #CONFIG += testlib to my ".pro" file. However, when I…
hashDefine
  • 1,491
  • 6
  • 23
  • 33
1
vote
1 answer

"no member named 'qt_metatype_id'" for QFETCH

I added this line to my QTestLib test class: QFETCH(MyType, value); When trying to compile the test class, I get this error: error: no member named 'qt_metatype_id' in 'QMetaTypeId'
jlstrecker
  • 4,953
  • 3
  • 46
  • 60
1
vote
1 answer

qmake incorrect target generation

I have a .pro file that looks like this: BASEDIR = ../../.. CLEBS *= buildplugin apextools apexdata apexmain TARGET = maintest TEMPLATE = app include($$BASEDIR/clebs.pri) CONFIG *= qtestlib QT *= testlib gui SOURCES *= \ apexmaintest.cpp…
cHaTrU
  • 95
  • 1
  • 9
1
vote
1 answer

Writing unit tests with QTestLib

this is my first step into the world on unit-testing so please be patient. I'm writing a Qt 4.8.1 C++ program and as test framework I'm using the integrated QTestLib. I should test a class that inhrerits from a base one and that loads a certain XML…
Stefano
  • 3,213
  • 9
  • 60
  • 101
1
vote
1 answer

How test QTableView edition with QTest?

I would like to simulate edition of a cell of QTableView with QTest. I have tried different approach but without any success: qtableview->show(); /* I think that in my unit test I should no need that, could you confirm ? */ QModelIndex modelIndex…
Alexis
  • 21
  • 3
0
votes
1 answer

QTestLib - Verifying non-const reference arguments

I'm currently building a unit test suite for my application, using QTestLib. It's generally pretty straight-forward, but I'm become stuck on how to verify 'return' arguments. For example, if I have a function: double pointLineSegmentDistance(const…
cmannett85
  • 21,725
  • 8
  • 76
  • 119
0
votes
1 answer

QSignalSpy error: No such signal when connecting a signal to a QSignalSpy

I am trying to test a Qt application that uses QML. Specifically, I want to test the connection between a signal emitted by a QML object and a slot in a C++ class. Here's the relevant code I'm working with: QQuickView…
0
votes
0 answers

Detect if QTest is running

I have a class which has multiple unit-tests. I run them every time in a main function using QTest::qExec(new Test_MyClass) call. I'd like to see some qDebug() output when operating with MyClass, but not while running tests. Are there any Qt…
Alexandr
  • 155
  • 2
  • 3
  • 13
0
votes
2 answers

Registering tests on QTest in CTest apart from executable like GTest realizations

I have an executable with multiple tests written with QTest. The executable is being registered using add_tests(NAME test_name COMMAND test_executable). Obviously, tests will be handled as one in CTest, so it will be difficult to find the problem if…
0
votes
2 answers

Select QMessageBox stored as local variable for QTest

I'm trying to test with QTest a GUI application. I can access to all the UI elements across the ui_class.h. The problem is, that I've created several QMessageBox on the main program as local variable and I need them to use QTest::mouseClick() when…
Manuninho
  • 31
  • 1
  • 6
0
votes
1 answer

QTestLib: Problem testing a Target = app

I have a problem with the dependencies in my unit testing project. My project structure is as follows: MyProject |---MyProject.pro |---src | |---src.pro | |---ClassA.h | |---ClassA.cpp | |---ClassB.h | …
Dimitrij
  • 81
  • 1
  • 2