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

How to access a QAction using the QtTest lib?

I have a pop-up menu in a QTableWidget (resultTable). In the constructor of my class I set the context menu policy: resultTable->setContextMenuPolicy(Qt::CustomContextMenu); connect(resultTable, SIGNAL(customContextMenuRequested(QPoint)), this,…
KelvinS
  • 2,870
  • 8
  • 34
  • 67
1
vote
1 answer

QTest executes test case twice

I've written a small benchmark in QTest, and although I've used QBENCHMARK_ONCE. Here some example code replicating the issue: header: #ifndef MY_TEST_H #define MY_TEST_H #include class MyTest : public QObject { Q_OBJECT private…
Benjamin Maurer
  • 3,602
  • 5
  • 28
  • 49
1
vote
1 answer

Qt test how to stop execution when a signal is emitted

I am currently testing a Qt application. I have to build a test to check the correct input and output of csv files. Problem: The data is being read asynchronously and my test program is ending before the data is loaded and this is the output i…
akashrajkn
  • 2,295
  • 2
  • 21
  • 47
1
vote
1 answer

How to test functions which do not return anything using QTestLib

I am new to unit testing and QTestLib. I could not find the answer to this particular problem. How do I test functions (or units) that do not return anything. I have read the tutorials given in the Qt site, but I do not know how to proceed. I have…
akashrajkn
  • 2,295
  • 2
  • 21
  • 47
1
vote
0 answers

QTest optional column in _data function

Is it possible to have optional columns in a _data() function, similar to optional arguments for functions - int foo(int a, int b=5). Something like: void Test1::testCase1_data() { QTest::addColumn("requiredCol"); …
sashoalm
  • 75,001
  • 122
  • 434
  • 781
1
vote
1 answer

How to use QCOMPARE Macro to compare events

I have MyWindow class which pops up a blank window, which accepts a mouse click, I need to unit test the mouse click event Code snippet: void TestGui::testGUI_data() { QTest::addColumn("events"); …
vels
  • 21
  • 4
1
vote
1 answer

How can I control when my gmock is verified?

Using 'another test framework' (Qt), I want to control when the google mocks are verified: void MyQtTest::test_ThisAndThat() { MyMock mock; EXPECT_CALL(mock, foo(1)); system_under_test.bar(); //VERIFY_EXPECTATIONS(mock) } But…
xtofl
  • 40,723
  • 12
  • 105
  • 192
1
vote
3 answers

c++ unit-tests sample in open-source-project

I'm interested in learning about c++-unit-testing in the 'real-world'. I'd like to see a complex class with good test-coverage. Preferably tested with g-test or qtestlib. I had a look at KDE and Chromium but didn't find what I wanted.
1
vote
1 answer

QTest::qExec Hide "passed" messages

I'm new in Qt and QTest. I use QTest::qExec(&someMyTestClassObject) to run my tests. Is possible to hide "PASS : MyClass::myTest" messages? Of course i want to see all "FAIL" messages and statistics Sorry for my poor English
Daiver
  • 1,488
  • 3
  • 18
  • 47
1
vote
2 answers

Is it possible to set data for testing in separate method in qt unit testing?

I saw that Qt supports a data function associated to a test function. http://qt-project.org/doc/qt-4.8/qtestlib-tutorial2.html Is it possible to have some similar type of data function for multiple tests ? Example: void Test::Test1() { …
Thalia
  • 13,637
  • 22
  • 96
  • 190
1
vote
2 answers

PySide - Click an item inside of a QTreeWidget with QTest

I'm developing an application with PySide. I'm doing the unit tests before writing any code in the application. I need to select an item inside QTreeWidget so I can use QTreeWidget.currentItem to retrieve it and do some stuff with it in order to…
shackra
  • 277
  • 3
  • 16
  • 56
1
vote
1 answer

Qtest access to ui member

I need to simulate mouse click on UI button using QTest but I can't figure out how to access it. I've got a MediaPanel class : class PhMediaPanel : public QWidget { Q_OBJECT public: explicit PhMediaPanel(QWidget *parent = 0); //... a…
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
1
vote
2 answers

Monitor/Output emitted Qt-Signals

I defined some signals which are emitted on different occasions: signals: void buttonXClicked(int x); void numButtonsChanged(int num); Now I would just like to see how these signals look like and if the parameters are correct. It seems…
Qohelet
  • 1,459
  • 4
  • 24
  • 41
1
vote
1 answer

How to run QTQuick test

how can I run tests for QtQuick-Applications in the main.cpp? The main.qml have a rectangle and inside some buttons. The test class MouseClick.qml implements the javascript test functions who should push the buttons. int main(int argc, char…
Andreas
  • 636
  • 1
  • 12
  • 29
1
vote
0 answers

Simplest way to click a button with QTest

Can somebody explain me the simplest way to click a button or something else like a QComboBox in a QTest? I tried this: QComboBox *type = new QComboBox(); type->addItem( "1" ); type->addItem( "2" ); type->addItem( "3" ); type->addItem( "4"…
Andreas
  • 636
  • 1
  • 12
  • 29