QTest namespace contains all the functions and declarations that are related to the QTestLib 工具。
请参考 QTestLib Manual documentation for information on how to write unit tests.
The enum specifies the kinds of test log messages.
| 常量 | 描述 |
|---|---|
| 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 |
注意
该枚举在 Qt 4.6 引入或被修改
This enum numbers the different tests.
| 常量 | 描述 |
|---|---|
| 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 |
注意
该枚举在 Qt 4.6 引入或被修改
This enum lists all the things that can be benchmarked.
| 常量 | 描述 |
|---|---|
| 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 |
另请参阅
QTest.benchmarkMetricName() QTest.benchmarkMetricUnit()
注意
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.
| 常量 | 描述 |
|---|---|
| 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. |
另请参阅
QEXPECT_FAIL()
This enum describes possible actions for mouse handling.
| 常量 | 描述 |
|---|---|
| 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.
| 常量 | 描述 |
|---|---|
| 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. |
另请参阅
QSKIP()
This enum describes possible actions for key handling.
| 常量 | 描述 |
|---|---|
| QTest.Press | 键被按下。 |
| QTest.Release | 键被释放。 |
| QTest.Click | 键被点击 (按下并释放)。 |
| 参数: |
|
|---|
| 参数: | ascii – PySide.QtCore.char |
|---|---|
| 返回类型: | 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.
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 返回类型: | str |
|---|
Returns the name of the current test data. If the test doesn't have any assigned testdata, the function returns 0.
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the current test function failed, otherwise false.
| 返回类型: | str |
|---|
Returns the name of the test function that is currently executed.
范例:
void MyTestClass.cleanup()
{
if (qstrcmp(currentTestFunction(), "myDatabaseTest") == 0) {
// clean up all database connections
closeAllDatabases()
}
}
| 参数: |
|
|---|
Ignores messages created by qDebug() or qWarning() 。若 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.
注意
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.
范例:
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.
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: | key – PySide.QtCore.Qt.Key |
|---|---|
| 返回类型: | PySide.QtCore.char |
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
Moves the mouse pointer to a widget 。若 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.
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|---|
| 返回类型: |
void |
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.bool |
| 参数: |
|
|---|---|
| 返回类型: |
void |
| 参数: |
|
|---|
| 参数: | window – PySide.QtGui.QWidget |
|---|---|
| 返回类型: | 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.
范例:
widget = QWidget()
widget.show()
QTest.qWaitForWindowShown(widget)
| 参数: |
|
|---|
| 参数: |
|
|---|
| 参数: |
|
|---|
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.
| 参数: |
|
|---|
| 返回类型: | PySide.QtCore.QObject |
|---|
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtTest.QTouchEventSequence |