[Qt-interest] QTest Lib: pass a cmd argument to a test function
Sarvesh Saran
Sarvesh.Saran at synopsys.com
Mon Jan 25 14:32:14 CET 2010
Hi,
I see. Well I am not really testing my application but what I really want to do is to automate certain events..
The idea is to feed input to my GUI application ( the input here is a file name which is generated dynamically by another script), click on certain buttons or actions and "operate" the GUI app. But I would like to do this automatically and was hoping to do so through the Test Lib.
Is there any other way I can achieve this? ( in this case the GUI app is a part of a test harness script and prepares certain reports/graphs from the input file..I would like to automate the report generation process)
Thanks,
Sarvesh
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Thiago Macieira
Sent: Monday, January 25, 2010 6:15 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QTest Lib: pass a cmd argument to a test function
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
More information about the Qt-interest-old
mailing list