The QTest namespace contains all the functions and declarations that are related to the QTestLib tool.
Please refer to the QTestLib Manual documentation for information on how to write unit tests.
The enum specifies the kinds of test log messages.
Constant | Description |
---|---|
QTest.LET_Undefined | |
QTest.LET_Property | |
QTest.LET_Properties | |
QTest.LET_Failure | |
QTest.LET_Error | |
QTest.LET_TestCase | |
QTest.LET_TestSuite | |
QTest.LET_Benchmark | |
QTest.LET_SystemError |
Note
This enum was introduced or modified in Qt 4.6
This enum numbers the different tests.
Constant | Description |
---|---|
QTest.AI_Undefined | |
QTest.AI_Name | |
QTest.AI_Result | |
QTest.AI_Tests | |
QTest.AI_Failures | |
QTest.AI_Errors | |
QTest.AI_Type | |
QTest.AI_Description | |
QTest.AI_PropertyValue | |
QTest.AI_QTestVersion | |
QTest.AI_QtVersion | |
QTest.AI_File | |
QTest.AI_Line | |
QTest.AI_Metric | |
QTest.AI_Tag | |
QTest.AI_Value | |
QTest.AI_Iterations |
Note
This enum was introduced or modified in Qt 4.6
This enum lists all the things that can be benchmarked.
Constant | Description |
---|---|
QTest.FramesPerSecond | Frames per second |
QTest.BitsPerSecond | Bits per second |
QTest.BytesPerSecond | Bytes per second |
QTest.WalltimeMilliseconds | Clock time in milliseconds |
QTest.CPUTicks | CPU time |
QTest.InstructionReads | Instruction reads |
QTest.Events | Event count |
See also
QTest.benchmarkMetricName() QTest.benchmarkMetricUnit()
Note
This enum was introduced or modified in Qt 4.7
This enum describes the modes for handling an expected failure of the QVERIFY() or QCOMPARE() macros.
Constant | Description |
---|---|
QTest.Abort | Aborts the execution of the test. Use this mode when it doesn’t make sense to execute the test any further after the expected failure. |
QTest.Continue | Continues execution of the test after the expected failure. |
See also
QEXPECT_FAIL()
This enum describes possible actions for mouse handling.
Constant | Description |
---|---|
QTest.MousePress | A mouse button is pressed. |
QTest.MouseRelease | A mouse button is released. |
QTest.MouseClick | A mouse button is clicked (pressed and released). |
QTest.MouseDClick | A mouse button is double clicked (pressed and released twice). |
QTest.MouseMove | The mouse pointer has moved. |
This enum describes the modes for skipping tests during execution of the test data.
Constant | Description |
---|---|
QTest.SkipSingle | Skips the current entry in the test table; continues execution of all the other entries in the table. |
QTest.SkipAll | Skips all the entries in the test table; the test won’t be executed further. |
See also
QSKIP()
This enum describes possible actions for key handling.
Constant | Description |
---|---|
QTest.Press | The key is pressed. |
QTest.Release | The key is released. |
QTest.Click | The key is clicked (pressed and released). |
Parameters: |
|
---|
Parameters: | ascii – PySide.QtCore.char |
---|---|
Return type: | PySide.QtCore.Qt.Key |
Convert an ascii char key value to a Qt Key value. If the key is unknown a 0 is returned.
Note: this may happen more than you like since not all known ascii keys _are_ converted already. So feel free to add all the keys you need.
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Return type: | str |
---|
Returns the name of the current test data. If the test doesn’t have any assigned testdata, the function returns 0.
Return type: | PySide.QtCore.bool |
---|
Returns true if the current test function failed, otherwise false.
Return type: | str |
---|
Returns the name of the test function that is currently executed.
Example:
void MyTestClass.cleanup()
{
if (qstrcmp(currentTestFunction(), "myDatabaseTest") == 0) {
// clean up all database connections
closeAllDatabases()
}
}
Parameters: |
|
---|
Ignores messages created by qDebug() or qWarning() . If the message with the corresponding type is outputted, it will be removed from the test log. If the test finished and the message was not outputted, a test failure is appended to the test log.
Note
Invoking this function will only ignore one message. If the message you want to ignore is outputted twice, you have to call PySide.QtTest.QTest.ignoreMessage() twice, too.
Example:
QDir dir
QTest.ignoreMessage(QtWarningMsg, "QDir.mkdir: Empty or null file name(s)")
dir.mkdir("")
The example above tests that QDir.mkdir() outputs the right warning when invoked with an invalid file name.
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: | key – PySide.QtCore.Qt.Key |
---|---|
Return type: | PySide.QtCore.char |
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Moves the mouse pointer to a widget . If pos is not specified, the mouse pointer moves to the center of the widget. If a delay (in milliseconds) is given, the test will wait before moving the mouse pointer.
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|---|
Return type: | void |
Parameters: |
|
---|---|
Return type: | PySide.QtCore.bool |
Parameters: |
|
---|---|
Return type: | void |
Parameters: |
|
---|
Parameters: | window – PySide.QtGui.QWidget |
---|---|
Return type: | PySide.QtCore.bool |
Waits until the window is shown in the screen. This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some time after being asked to show itself on the screen. Returns true.
Example:
widget = QWidget()
widget.show()
QTest.qWaitForWindowShown(widget)
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: |
|
---|
Sets the benchmark result for this test function to result .
Use this function if you want to report benchmark results without using the QBENCHMARK macro. Use metric to specify how QTestLib should interpret the results.
The context for the result will be the test function name and any data tag from the _data function. This function can only be called once in each test function, subsequent calls will replace the earlier reported results.
Note that the -iterations command line argument has no effect on test functions without the QBENCHMARK macro.
Parameters: |
|
---|
Return type: | PySide.QtCore.QObject |
---|
Parameters: |
|
---|---|
Return type: | PySide.QtTest.QTouchEventSequence |