[Qt-interest] QTest Lib: pass a cmd argument to a test function

Thiago Macieira thiago at kde.org
Mon Jan 25 13:44:42 CET 2010


Em Segunda-feira 25 Janeiro 2010, às 12:26:51, Sarvesh Saran escreveu:
> Hi,
> 
> I'm having multiple issues with QTest:Lib..
> 
> 
> *         I would like to pass a cmd argument to a test function readFile()
> ..however I am unable to figure out how to do this. The class looks
> something like this:
> class MyTest : public QObject
> {
>     Q_OBJECT
> 
> private slots:
>     void initTestCase();
>     void cleanupTestCase();
> void readFile(QString filename);
> void ...
> void ...
> 
> private:
> ......
> }
> 
> This is then called from main.cpp as:
> int main(int argc, char *argv[])
> {
>     QApplication a(argc, argv);
> 
>     MyTest  test;
>     QTest::qExec(&test);
> }
> 
> But how do I past the cmd argument "filename" to the function readFile ?
> besides I would like to call only this particular test function with the
> arg and ignore the other tests. Any ideas would be appreciated.

That is not possible. Use _data functions and QFETCH.

See http://doc.trolltech.com/4.6/qtest.html#QFETCH.

Also, your main function should be:

QTEST_MAIN(MyTest)

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100125/c5e760a9/attachment.bin 


More information about the Qt-interest-old mailing list