path: root/src/testlib
diff options
authorLiang Qi <>2019-12-10 13:51:40 +0200
committerLiang Qi <>2019-12-10 13:51:40 +0200
commit90210d5d9c4029057035019f144212922494ff0a (patch)
tree1aacefa57786964d47a200791280ae91c9b825da /src/testlib
parentc69a2448ab129d88411a4778f2350dcf971dc623 (diff)
parent5231c26a82a7056f98d99643850754d4e1ebe417 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts: tests/auto/network/kernel/qnetworkinterface/BLACKLIST Change-Id: I1e8866c63b54bcd95fc2a044276ee15b7f60e79a
Diffstat (limited to 'src/testlib')
2 files changed, 55 insertions, 2 deletions
diff --git a/src/testlib/doc/snippets/code/doc_src_cmakelists.txt b/src/testlib/doc/snippets/code/doc_src_cmakelists.txt
new file mode 100644
index 0000000000..96dbe1acee
--- /dev/null
+++ b/src/testlib/doc/snippets/code/doc_src_cmakelists.txt
@@ -0,0 +1,14 @@
+project(mytest LANGUAGES CXX)
+find_package(Qt5Test REQUIRED)
+add_executable(mytest tst_mytest.cpp)
+add_test(NAME mytest COMMAND mytest)
+target_link_libraries(mytest PRIVATE Qt5::Test)
diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc
index 19d871d404..688cc2f2f6 100644
--- a/src/testlib/doc/src/qttestlib-manual.qdoc
+++ b/src/testlib/doc/src/qttestlib-manual.qdoc
@@ -83,6 +83,10 @@
\li Custom types can easily be added to the test data and test output.
+ You can use a Qt Creator wizard to create a project that contains Qt tests
+ and build and run them directly from Qt Creator. For more information, see
+ \l {Running Autotests}.
\section1 Creating a Test
To create a test, subclass QObject and add one or more private slots to it. Each
@@ -133,6 +137,41 @@
\if !defined(qtforpython)
\section1 Building a Test
+ You can build an executable that contains one test class that typically
+ tests one class of production code. However, usually you would want to
+ test several classes in a project by running one command.
+ See \l {Chapter 1: Writing a Unit Test}{Writing a Unit Test} for a step by
+ step explanation.
+ \section2 Building with CMake and CTest
+ You can use \l {CMake and CTest} to create a test.
+ \l{}{CTest} enables
+ you to include or exclude tests based on a regular expression that is
+ matched against the test name. You can further apply the \c LABELS property
+ to a test and CTest can then include or exclude tests based on those labels.
+ All labeled targets will be run when \c {test} target is called on the
+ command line.
+ There are several other advantages with CMake. For example, the result of
+ a test run can be published on a web server using CDash with virtually no
+ effort.
+ CTest scales to very different unit test frameworks, and works out of the
+ box with QTest.
+ The following is an example of a CMakeLists.txt file that specifies the
+ project name and the language used (here, \e mytest and C++), the Qt
+ modules required for building the test (Qt5Test), and the files that are
+ included in the test (\e tst_mytest.cpp).
+ \quotefile code/doc_src_cmakelists.txt
+ For more information about the options you have, see \l {Build with CMake}.
+ \section2 Building with qmake
If you are using \c qmake as your build tool, just add the
following to your project file:
@@ -146,14 +185,14 @@
See the \l{Building a Testcase}{qmake manual} for
more information about \c{make check}.
+ \section2 Building with Other Tools
If you are using other build tools, make sure that you add the location
of the Qt Test header files to your include path (usually \c{include/QtTest}
under your Qt installation directory). If you are using a release build
of Qt, link your test to the \c QtTest library. For debug builds, use
- See \l {Chapter 1: Writing a Unit Test}{Writing a Unit Test} for a step by
- step explanation.
\section1 Qt Test Command Line Arguments