Testcase Item¶
-
class
Testcase¶ Implements a test action.
| Locations: | Project, document root |
|---|---|
| Nested items: | Component, Depends, Exports,
Matrix |
| Enumerations: | Result |
| Properties: | dependencies, elapsedTime, name,
result, workingDirectory |
| Methods: | run(), |
| Signals: | created(), destruction(), finished(),
started() |
Detailed Description¶
A Testcase component combines probes, constraints and other QML components
into a single test case. It is executed as one atomic entity. Every test case
must have a unique name throughout the project and must implement a
run() method.
Example:
import qst 1.0
Testcase {
name: "test-myprocess"
ProcessProbe {
id: process
command: "/usr/bin/echo"
arguments: [
"Hello World"
]
}
function run() {
process.start();
process.waitForFinished(100);
Qst.compare(process.readAllStandardOutput(), "Hello World");
// Testcase will finish with result 'Pass'
}
}
Enumerations¶
Properties¶
-
var
dependencies¶ When the test case contains a
Dependsitems, this property makes exported values for every dependencynameoraliasaccessible. Data forwarded byExportscan be accessed in bindings and code. Dependencies are always attached in list form beause a test case might be represented by multiple jobs:simple-exports.qml¶Depends { name: "A" } function run() { Qst.info("A was " + dependencies.A[0].result) }
This property is read-only.
-
uint64
elapsedTime¶ Time in milliseconds since the test case was started.
This property is updated on every read access and cannot be used as a binding.
-
string
name¶ Identifier for this test case. This property must be a plain string and must be unique across the whole project.
The default value is an empty string.
-
Result
result¶ The outcome of a test case run. The default value is
Result::Unfinished.
-
const string
workingDirectory¶ A unique directory where the current test case and child components may store files. The directory may be used for log files or as scratch pad and is always created on execution start.
The default value is
project.workingDirectory + "/" + nameand cannot be changed by the test case.
Methods¶
-
void
run()¶ Contains the execution code and is called when the test case starts. It has to be implemented by the user. The
run()method may contain several other blocking calls to methods and functions. It will return only for two reasons:- All statements have been executed.
resultwill be set toResult::Pass. - An error has occurred or a constraint has failed and
resulthas been set toResult::Fail. In that case, all remaining statements are aborted.
- All statements have been executed.
Signals¶
-
void
created()¶ This signal is emitted after the
destruction()signal of the previousTestcaseand beforestarted()of the current one. It is the QML way of implementing a constructor and can be used to initialize resources.The signal is also attached to every
ComponentasTestcase.created().
-
void
destruction()¶ This signal is emitted before the
Testcasecomponent is physically destroyed and may be used to free up resources.The signal is also attached to every
ComponentasTestcase.destruction().
-
void
finished()¶ This signal is emitted after the
run()function has returned and may be used for final evaluation or cleaning up. By that time,resultmay not have been set, yet and thus, it is still allowed to call verification functions.The signal is also attached to every
ComponentasTestcase.finished().