Results 1 to 5 of 5

Thread: How to write automated tests for my app?

  1. #1
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    6
    Thanked 10 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to write automated tests for my app?

    Hello

    I have custom Application class (QApplication descendant) which is the core of my app (it handle application states and create windows when needed). And I want to write automated tests for my app (to ensure quality). I found that page:
    http://qt.nokia.com/learning/online/...-applications/
    And I recognize that in order to test my app I should make it as shared library (or maybe few shared libraries).
    But mentioned page apparently assume that default QApplication is used. So I have question:
    How I should manage my own custom QApplication descendant in the test suit?
    Maybe I should create my QApplication object but not call exec() function?
    Will that work?

    thanx
    Szyk

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to write automated tests for my app?

    The first thing to mention is to define what you want to test as "testing" is a very broad term.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    6
    Thanked 10 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to write automated tests for my app?

    Ritght!
    I want write test to perform about 20 typical user actions. (typical "positive" use cases). This will be purely GUI simulation.
    One of that tests should be done like that: (open login window), type username, type passowrd, click Ok, (connection in the background)(close login window)(open main window), type some text, push enter, click icon (open related window), click some icon (in related window), click close button (close related window), push enter, hit alt+f4 (close main window).
    Then next similar test should be performed.
    Last edited by oficjalne100; 11th March 2012 at 18:37.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to write automated tests for my app?

    Quote Originally Posted by oficjalne100 View Post
    Ritght!
    I want write test to perform about 20 typical user actions. (typical "positive" use cases). This will be purely GUI simulation.
    One of that tests should be done like that: (open login window), type username, type passowrd, click Ok, (connection in the background)(close login window)(open main window), type some text, push enter, click icon (open related window), click some icon (in related window), click close button (close related window), push enter, hit alt+f4 (close main window).
    Then next similar test should be performed.
    QtTestLib is not great at things like that. It's more suited to unit-testing.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    6
    Thanked 10 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: How to write automated tests for my app?

    Ok! I try to write some automated tests "positive use cases" of my application. And it almost works (I have problem with main menu simulated clicks, but probably it is not related to whole "positive use cases" tests concept). I do it as follow:
    1. Write test object - it should create QApplication (or its descendant) in initTestCase() and delete them in cleanupTestCase(), other slots should perform tests (as usual in QTestLib)
    1. Detect "--demo" parameter in main(), and remove it from parameters list (or create QStringList with all parameters except "--demo") to avoid fatal error in QTest::qExec
    2. Create in main() test object (e.g. called lTest)
    3. Call in main(): return QTest::qExec(&lTest, lParams); In that case lParams is mentioned QStringList with main() parameters (except "--demo") converted from plain asci to QString.

Similar Threads

  1. Replies: 3
    Last Post: 11th November 2012, 21:17
  2. Qt unit testing using Google Tests
    By Archa4 in forum Newbie
    Replies: 4
    Last Post: 11th May 2011, 10:35
  3. I do not understand as to start qt tests for gui
    By Chexov in forum Qt Programming
    Replies: 0
    Last Post: 15th April 2010, 15:50
  4. Unit tests
    By leoalvesmachado in forum Newbie
    Replies: 1
    Last Post: 13th April 2010, 20:50
  5. how to best separate tests from source
    By Rockem in forum Qt Programming
    Replies: 0
    Last Post: 24th September 2009, 23:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.