The Qt Test module provides classes for unit testing Qt applications and libraries. All public methods are in the QTest 名稱空間。此外, QSignalSpy 類提供對 Qt 的信號和槽的輕鬆自省,而 QAbstractItemModelTester 允許非破壞性測試項模型。
注意: Qt Test 模塊沒有二進製兼容性保證。這意味著使用 Qt Test 的應用程序隻保證與開發時所針對的 Qt 版本一起時纔能工作。不管怎樣,源代碼的兼容性是有保證的。
Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake .
使用
find_package()
command to locate the needed module component in the
Qt6
包:
find_package(Qt6 REQUIRED COMPONENTS Test)
target_link_libraries(mytarget PRIVATE Qt6::Test)
更多細節,見 構建采用 CMake 概述。
To configure the module for building with qmake, add the module as a value of the
QT
variable in the project's .pro file:
QT += testlib
The Qt Quick Test module enables unit testing of Qt Quick applications.
Qt Test 的變化 lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.
Qt Test 模塊在商業許可下是可用的來自 Qt 公司 . In addition, it is available under free software licenses: The GNU LGPL (次一般公共許可) 第 3 版 ,或 GNU GPL (一般公共許可) 第 2 版 。見 Qt 許可 進一步瞭解細節。
Furthermore, Qt Test in Qt 6.5.1 may contain third party modules under the following permissive licenses:
| Catch2, version 2.13.10 | Boost 軟件許可 1.0 |
| Cycle | MIT 許可 |
| Linux 性能事件第 3.7 版 | GNU GPL (一般公共許可) 第 2.0 版僅采用 Linux Syscall 注意 |
| Valgrind, version 3.20.0 | BSD 4 條款原始或舊的許可 |