QTestLib 介绍ppt稿

 

QTestLib


Author :           Tao Xia
Date:              2009-3-17

1. Basic Method About QTestLib

=====================================


(1) QT += testlib, #include <QTest>

(2) A class inherite from QObject.

(3) slots function to hold test content.

(4) Data_Driven function.   

   void QTestClass::funcName()
    {
        QFETCH(Type, Name);
        QFETCH(Type, Name2);
        ...

    }
       
    void QTestClass::funcName_data()
    {
        QTest::addColumn<Type>("Name");
        QTest::addColumn<Type>("Name2");
        ...

        QTest::newRow("Description")<< value1 << value2 << ...
        QTest::newRow("Description")<< value1 << value2 << ...
    }

 
(5) KEY words:
    
    QCOMPARE(para1, para2); 
    QVERIFY(boolPara);   
    QTEST_MAIN(ClassName)                // Put anywhere cpp.
    Q_DECLARE_METATYPE(TYPE)         // To support self-define data type.

2. QTestLib example in PhoneAPI UT.

=====================================

(1) Project File, the files including problem.
(2) On-Off, condition select.
(3) Test data preparation.
(4) Completely auto test.

3. GUI Test

=====================================

    QTest::keyClicks()    //KeyAction

QTest::keyClicks(myWidget, "hello world");

    QTest::keyClick()     //

 QTest::keyClick(myWidget, Qt::Key_Escape, Qt::ShiftModifier, 200);

    QTest::mouseClick()      //MouseAction

   
void QTest::mouseClick ( QWidget

 * widget, Qt::MouseButton

 button,Qt::KeyboardModifiers

 modifier = 0, QPoint

 pos = QPoint(), int delay= -1 )

 void TestGui::testGui() {
QLineEdit lineEdit;
QTest::keyClicks(&lineEdit, "hello world");
QCOMPARE(lineEdit.text(), QString("hello world"));
}

 

4. Stub

=====================================


在计算机软件中,stub表示一小段特殊代码.主要起到承上启下的作用或者提示作用.下面是glibc手册中相关内容的描述:
http://www.gnu.org/software/libc/manual/html_node/Porting.html
----
If it is possible to implement the routines in a generic file in machine-independent C, using only other machine-independent functions in the C library, then you should do so. Otherwise, make them stubs. A stub function is a function which cannot be implemented on a particular machine or operating system. Stub functions always return an error, and set errno to ENOSYS (Function not implemented). See Error Reporting. If you define a stub function, you must place the statement stub_warning(function), where function is the name of your function, after its definition; also, you must include the file <stub-tag.h> into your file. This causes the function to be listed in the installed <gnu/stubs.h>, and makes GNU ld warn when the function is used.


5. Unit Test
=====================================

http://msdn.microsoft.com/en-us/magazine/cc163665.aspx
http://www.ibm.com/developerworks/cn/java/j-test/
http://www.miiceic.org.cn/phrase/200602281036115.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值