[Interest] Unit test with multiple data

Soroush Rabiei soroush.rabiei at gmail.com
Tue Jan 28 09:38:42 CET 2014


On Tue, Jan 28, 2014 at 6:45 AM, Tony Rietwyk <tony at rightsoft.com.au> wrote:
>
> Hi Soroush,
>
>
>
> I hit the same problem, and used this:
>
>
>
> // Can't use QTEST_MAIN, since we have our own parameters as well.
>
> // QTEST_MAIN( TTestPitchXml )
>
>
>
> int main(int argc, char *argv[])
>
> {
>
> #ifdef QT_GUI_LIB
>
>     QApplication app(argc, argv);
>
>     QTEST_DISABLE_KEYPAD_NAVIGATION
>
> #else
>
>     QCoreApplication app(argc, argv);
>
> #endif
>
>     TTestPitchXml tc;
>
>     QStringList args( app.arguments() );
>
>     tc.checkArgs( args );
>
>     return QTest::qExec(&tc, args);
>
> }
>
>
>
> Hope that helps,
>
>
>
> Tony

Hi Tony

I've implemented something similar to your answer. In my test class
parseArgs removes invalid arguments from list and then passes remaining
args (who will be parsed by QTest)  to qExec. (Is this similar to what
checkArgs do?) In my test, users can invoke test suite like this:

test_program [options] [testfunctions[:testdata]] --disable-odbc
--enable-mysql --database TestDB --username DBUser --password DBPassword

where "[options] [testfunctions[:testdata]]" are those described here[1]

Cheers

[1]:
http://qt-project.org/doc/qt-4.8/qtestlib-manual.html#qtestlib-command-line-arguments
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140128/40642a85/attachment.html>


More information about the Interest mailing list