diff options
Diffstat (limited to 'doc/src/index.qdoc')
-rw-r--r-- | doc/src/index.qdoc | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc new file mode 100644 index 0000000..4ba4840 --- /dev/null +++ b/doc/src/index.qdoc @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page index.html + \title QtQuickTest Reference Documentation + \keyword QtQuickTest Reference Documentation + + \section1 Introduction + + QtQuickTest is a unit test framework for Qt Quick (QML) applications. + Test cases are written as JavaScript functions within a TestCase + element: + + \code + import QtQuick 1.0 + import QtQuickTest 1.0 + + TestCase { + name: "MathTests" + + function test_math() { + compare(2 + 2, 4, "2 + 2 = 4") + } + + function test_fail() { + compare(2 + 2, 5, "2 + 2 = 5") + } + } + \endcode + + Functions whose names start with \c{test_} are treated as test cases + to be executed. See the documentation for the \l TestCase element + for more information on writing test cases. + + \section1 Building QtQuickTest + + Build QtQuickTest against Qt 4.7 as follows: + + \code + $ /path/to/qt/bin/qmake qtest-qml.pro + $ make + $ make install + \endcode + + The "make install" step copies the necessary libraries, plugins, + and QML module definitions into the Qt build tree. + + You can then run "make check" to verify that the example tests + pass correctly, and "make docs" to generate the HTML documentation + under \c{doc/html}. + + \section1 Running tests + + Test cases are launched by a C++ harness that consists of + the following code: + + \code + #include <QtQuickTest/quicktest.h> + QUICK_TEST_MAIN(qmlexample) + \endcode + + Where "qmlexample" is an identifier to use to uniquely identify + this set of tests. You should add \c{CONFIG += qmltestcase} to your + .pro file; for example: + + \code + TEMPLATE = app + TARGET = tst_qmlexample + CONFIG += warn_on qmltestcase + SOURCES += tst_qmlexample.cpp + RESOURCES += qmlexample.qrc + \endcode + + The test harness scans recursively for "tst_*.qml" files in the qrc + resources that are bound into the test harness binary. The following + is an example .qrc file: + + \code + <!DOCTYPE RCC><RCC version="1.0"> + <qresource> + <file>tst_basic.qml</file> + <file>tst_item.qml</file> + </qresource> + </RCC> + \endcode + + The \c{QUICK_TEST_SOURCE_DIR} macro can be defined at compile time to + run tests from plain files without binding them into resources. + Modify your .pro file to include the following line: + + \code + DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" + \endcode + + The \c{QUICK_TEST_SOURCE_DIR} environment variable can also be set + at runtime to run test cases from a different directory. This may + be needed to run tests on a target device where the compiled-in + directory name refers to a host. + + Other *.qml files may appear for auxillary QML components that are + used by the test. + + See \c{tests/qmlexample} in the source tree for an example of creating a + test harness that uses resources and \c{tests/qmlauto} for an example + that uses the \c{QUICK_TEST_SOURCE_DIR} macro. + + If your test case needs QML imports, then you can add them as + \c{-import} options to the the test program command-line by adding + the following line to your .pro file: + + \code + IMPORTPATH += $$PWD/../imports/my_module1 $$PWD/../imports/my_module2 + \endcode +*/ |