Questions tagged [qttest]

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

Documentation can be found here.

81 questions
1
vote
1 answer

Qt unit testing: QCOMPARE function on list of pointers

Does Qt testing framework support comparing list of pointers or I am doing something wrong? My unit test source is as follows: QList list1; QList list2; list1.append(new QString("test")); list2.append(new…
franz
  • 312
  • 3
  • 15
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

Error when calling qExec "no known conversion for argument 1 to QObject"

I'm trying to create tests for a c++ application with QtTest. The three relevent files that I have are: GuiTests.cpp which contains my main function, testsuite1.cpp which contains my tests and testsuite1.h which contains the definitions of my tests.…
molundb
  • 484
  • 1
  • 4
  • 18
1
vote
0 answers

How do I test method that reads data from file

I have a class with following constructor: MyClass(QFile& file);. I want to unit-test it with Qt Test framework. How do I specify content of the file from a unit-test (without actually creating a real file)?
Vlad Shevchenko
  • 738
  • 1
  • 8
  • 19
1
vote
0 answers

How do you write a failing Qt Test that generates BFAILs and BPASSes?

When searching through Qt files to for all the different Qt Test results, I came across BPASS and BFAIL. I'd like to write some passing/failing tests. The problem is, I can't find any examples of people writing tests that generate these results, and…
kayleeFrye_onDeck
  • 6,648
  • 5
  • 69
  • 80
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

QTest::keyPress is not returning nativeScanCode

I am simulating F1 key using QTest::keyPress() method to test keypress event, on simulation of F1 key when i check for nativeScanCode, it returns 0 value. can any one help? //Code snippet //To simulate F1 key press QTest::keyPress(&kboard,…
vels
  • 21
  • 4
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

QtTest is failing when comparing strings, Even though they're identical? C++

I have a QtTest that is comparing two string values: // This definitely returns "5/6" std::string actual_value = simple(actual); // Sets a string to the expected value std::string expected_value = "5/6"; and then a…
AngryDuck
  • 4,358
  • 13
  • 57
  • 91
1
vote
2 answers

Not sure how to use QtTest

I want to do unit testing for some simple exercises i have done in c++ using Qt. i figured using QtTest seemed like a reasonable place to start. i have a class that returns an integer and i want to test that the expected result is the same as the…
AngryDuck
  • 4,358
  • 13
  • 57
  • 91
1
vote
1 answer

Testing my class with QTestLib

I need to make some unit test for my school project in Qt and although I have read Qt tutorial on that I can't figure out how am I supposed to write such tests. All of tests shown in tutorial I've mentioned refer to built-in methods. How should I…
jahsiotr
  • 141
  • 1
  • 11
0
votes
1 answer

How do I use QTest::keyClick with control characters?

I am trying to simulate user input to close a window. I try to use QTest::keyClick(Qt::key::Key_F4, myWidget, Qt::KeyboardModifiers{ Qt::KeyboardModifier::AltModifier }); to simulate the user clicking the Alt+F4 keyboard combo, but it does not…
0
votes
0 answers

When should SignalSpy be used in QML?

I'm seeing an issue in my QML animation, where very rarely, a state transition animation does not happen. I was searching online why that might be and came across SignalSpy. How and when should someone use it? The example is confusing, I thought it…
Evan Krause
  • 147
  • 1
  • 16
0
votes
0 answers

How to capture Qt QBENCHMARK output to a file?

I run an exe that benchmarks C++ code on my Windows Embedded Compact (WEC2013) i.MX6 platform over telnet. Results go to the serial port and I cannot redirect them to a file, which would be ideal. My benchmark uses QBENCHMARK and works as expected…
pixelgrease
  • 1,940
  • 23
  • 26
0
votes
0 answers

QBENCHMARK with different data

Is it possible to perform benchmarking with QBENCHMARK with a different data point each time a measurement is made? To be more specific, I have the following test case: void TestImage::test_IMCreationBenchmark_data() { const uint HEIGHT = 480; …
mahasamatman
  • 603
  • 1
  • 7
  • 10