SAM
SAM

Reputation: 395

Qt Unit Testing

I am new to Qt and unit testing. I have gone through the documentation and example of unit testing, but i couldnt figure out how to use the test scenario's in an application.

For eg. In the documentation a QLineEdit is created and then the value is checked with a specific value.

void testGUI()
{
   QLineEdit lineEdit;
   QTest::keyClicks(&lineEdit, "Hello");
   QCOMPARE(lineEdit.text(),QString("Hello"));
}

When i run the program all the result is shown in the console.

But how can i check if i have a QLineEdit and a QPushButton in a QMainWindow form.

How to do GUI Testing ?

Upvotes: 3

Views: 2821

Answers (2)

Atif
Atif

Reputation: 1537

Unit testing usually doesn't include the user interface. Unit testing should be the low level, testing of each unit (class/component). Then integration testing tests the units working together to accomplish something. Sometimes mock objects are employed here to act as stand ins for other components, so verify the behaviour is what you'd expect.

After you have unit testing and integration testing handled, the UI testing should be pretty strait forward. For a Qt project, the cross platform gui testing framework from froglogic called squish might be your best bet. However it is a paid product, and if you don't need its cross platform nature, you may be able to get away with some free tools. Most come down to running your application under some sort of instrumentation, and then it replaying your interactions with the user interface, and verifying the values of text fields etc.

Anyway I believe XCode and Visual Studio provide some basic ui unit testing tools. Their is also a wikipedia article here.

Upvotes: 0

aayoubi
aayoubi

Reputation: 12069

You seem to be looking into GUI unit-testing.

Here you go: How can I unit test a GUI?

Upvotes: 3

Related Questions