Qt Creator, free download. Qt Creator 4.6.2: Qt Creator is a cross-platform IDE (integrated development environment) tailored to the needs of Qt developers.It is part of the Qt Project qt-project.org. Download qt packages for ALTLinux, CentOS, Fedora, Mageia, OpenMandriva, openSUSE, PCLinuxOS, ROSA, Slackware.
For those making use of the Qt 5.9 long-term support series, Qt 5.9.6 was outed today by The Qt Company. Qt 5.9.6 ships with various bug fixes/improvements, including a new addition of binary installers for QNX7. Qt 5.9 had already supported QNX 7, but was only shipping binaries for QNX 6.6. Qt 5.9.6 has 33 known bug fixes while close to 200 overall changes over Qt 5.9.5. More details on Qt 5.9.6 via today's release announcement. Qt Creator 4.6.2 is also out as the latest bug-fix release for this Qt/C++ focused integrated development environment.
By Yuri Farias.
This article shows how to create a unique Test Project containing all unit-tests for a project. This project holds every test for every single class in the main project.
This is very useful to give your project a more organized aspect, since the ‘testing’ will get separated from the main project.
Creating and Developing the Project
First, you have to create and develop your project, for this article we created a basic project which contains two classes: Circle and Square, both containing methods to create, manipulate and get information about the Geometry Forms. It is a basic console project, just for testing purpose.
Download Project
Download the project here.
Creating the Test Project - .pro File
You can simply create a normal project using QtCreator, based on your original Project (having the same configs), here is the .pro File of the TestProject:
It is basically the same model as QtCreator uses, but with some modifications. For example, you have to add testlib on QT var, and your target has to be a new class, in this case named maintest. As i said, you have to input the same configurations as you have in your original project, if your testing classes use, so keep sure you add the right libs and configs on your .pro file.
You also have to input the files from your original project in order to use it in your Test Classes.
Creating the Test Project - Test Classes
In the .pro file, we have already 4 sources and 4 headers, 2 of them are for the testing classes(importing them), and the other 2 are for the Test Classes, you can simply create them using QtCreator, a basic class. Here is the header from one of them:
Test Methods must be private slots, otherwise they will not be executed.
Try to always do the initTestCase() and cleanupTestCase() methods, so they can be executed at the startup and at the end of the test. Those methods usually are to create and delete objects, as you can see in the example. If you don't create them, they will be “executed” anyway but will do nothing.
The methods between them are test cases. It's always good to organize them by methods, or at least sections, so the code can be more readable.
Creating the Test Project - Testing Methods
In the .cpp file, there are some methods you can use from testlib, some of them are: QCOMPARE (Verify 2 values to check if they are the same), QVERIFY (Verify if the value is true), and so many others you can see in the QTest Documentation ( http://doc.trolltech.com/4.5/qtest.html).
Creating the Test Project - Main File
Ok, it's time to write the Main Class. You have to create an Object for each TestClass and execute them with the qExec method from QTest. In our example, the main class looks like this: