/usr/share/qt5/doc/qtdoc/qtquick-qtquicktest.html is in qt5-doc-html 5.3.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qtquicktest.qdoc -->
<title>Qt Quick Test Reference Documentation | QtDoc 5.3</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li><a href="index.html">Qt 5.3</a></li>
<li>Qt Quick Test Reference Documentation</li>
<li id="buildversion">
Qt 5.3.2 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#introduction">Introduction</a></li>
<li class="level1"><a href="#running-tests">Running tests</a></li>
</ul>
</div>
<h1 class="title">Qt Quick Test Reference Documentation</h1>
<span class="subtitle"></span>
<!-- $$$qtquick-qtquicktest.html-description -->
<div class="descr"> <a name="details"></a>
<a name="introduction"></a>
<h2>Introduction</h2>
<p><a href="../qtquick/qttest-qmlmodule.html">Qt Quick Test</a> is a unit test framework for QML applications. Test cases are written as JavaScript functions within a <a href="../qtquick/qml-qttest-testcase.html">TestCase</a> type:</p>
<pre class="cpp">import <span class="type"><a href="../qtquick/qtquick-module.html">QtQuick</a></span> <span class="number">2.3</span>
import <span class="type"><a href="../qttestlib/qttest-module.html">QtTest</a></span> <span class="number">1.0</span>
TestCase {
name: <span class="string">"MathTests"</span>
function test_math() {
compare(<span class="number">2</span> <span class="operator">+</span> <span class="number">2</span><span class="operator">,</span> <span class="number">4</span><span class="operator">,</span> <span class="string">"2 + 2 = 4"</span>)
}
function test_fail() {
compare(<span class="number">2</span> <span class="operator">+</span> <span class="number">2</span><span class="operator">,</span> <span class="number">5</span><span class="operator">,</span> <span class="string">"2 + 2 = 5"</span>)
}
}</pre>
<p>Functions whose names start with <tt>test_</tt> are treated as test cases to be executed. See the documentation for the <a href="../qtquick/qml-qttest-testcase.html">TestCase</a> and <a href="../qtquick/qml-qttest-signalspy.html">SignalSpy</a> types for more information on writing test cases.</p>
<a name="running-tests"></a>
<h2>Running tests</h2>
<p>Test cases are launched by a C++ harness that consists of the following code:</p>
<pre class="cpp"><span class="preprocessor">#include <QtQuickTest/quicktest.h></span>
QUICK_TEST_MAIN(example)</pre>
<p>Where "example" is the identifier to use to uniquely identify this set of tests. You should add <tt>CONFIG += qmltestcase</tt>. for example:</p>
<pre class="cpp">TEMPLATE <span class="operator">=</span> app
TARGET <span class="operator">=</span> tst_example
CONFIG <span class="operator">+</span><span class="operator">=</span> warn_on qmltestcase
SOURCES <span class="operator">+</span><span class="operator">=</span> tst_example<span class="operator">.</span>cpp</pre>
<p>The test harness scans the specified source directory recursively for "tst_*.qml" files. If <tt>QUICK_TEST_SOURCE_DIR</tt> is not defined, then the current directory will be scanned when the harness is run. Other *.qml files may appear for auxillary QML components that are used by the test.</p>
<p>The <tt>-input</tt> command-line option can 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. For example:</p>
<pre class="cpp">tst_example <span class="operator">-</span>input <span class="operator">/</span>mnt<span class="operator">/</span>SDCard<span class="operator">/</span>qmltests</pre>
<p>It is also possible to run a single file using the <tt>-input</tt> option. For example:</p>
<pre class="cpp">tst_example <span class="operator">-</span>input data<span class="operator">/</span>test<span class="operator">.</span>qml</pre>
<pre class="cpp">tst_example <span class="operator">-</span>input <span class="operator"><</span>full_path<span class="operator">></span><span class="operator">/</span>test<span class="operator">.</span>qml</pre>
<p><b>Note: </b>Specifying the full path to the qml test file is for example needed for shadow builds.</p><p>If your test case needs QML imports, then you can add them as <tt>-import</tt> options to the test program command-line by adding the following line to your .pro file:</p>
<pre class="cpp">IMPORTPATH <span class="operator">+</span><span class="operator">=</span> $$PWD<span class="operator">/</span><span class="operator">.</span><span class="operator">.</span><span class="operator">/</span>imports<span class="operator">/</span>my_module1 $$PWD<span class="operator">/</span><span class="operator">.</span><span class="operator">.</span><span class="operator">/</span>imports<span class="operator">/</span>my_module2</pre>
<p>The <tt>-functions</tt> command-line option will return a list of the current tests functions. It is possible to run a single test function using the name of the test function as an argument. For example:</p>
<pre class="cpp">tst_example Test_Name<span class="operator">::</span>function1</pre>
<p>The <tt>-help</tt> command-line option will return all the options available.</p>
<pre class="cpp">tst_example <span class="operator">-</span>help</pre>
</div>
<!-- @@@qtquick-qtquicktest.html -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2014 Digia Plc and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|