Create Qt tests | Qt Creator Manual

- Qt Creator Manual
- Create Qt tests
- Qt Creator Manual 13.0.1

How To

# Create Qt tests

Qt Creator integrates the Qt Test framework for unit testing Qt applications and libraries.

To create a Qt test:

1. Go to File > New Project > Test Project.
2. Select Qt Test Project > Choose.
3. In the Project and Test Information dialog, specify settings for the project and test.

4. In Test case name, enter a name for the test case.
5. Select Requires QApplication to add the include statement for QApplication to the main.cpp file of the project.
6. Select GUI Application to create a Qt application.
7. Select Generate initialization and cleanup code to add functions to your test that the testing framework executes to initialize and clean up the test.
8. In Build system, select the build system to use for building the project: CMake, qmake, or Qbs.

Qt Creator creates the test in the specified project directory. Edit the .cpp file to add private slots for each test function in your test.

For more information about creating Qt tests, see Creating a Test.

See also How To: Test, Select the build system, Testing, and Test Results.

How To