Results 1 to 5 of 5

Thread: Misunderstanding QTestLib's TestCase term

  1. #1
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Misunderstanding QTestLib's TestCase term

    Hello, guys.

    I was just developing unit tests for my application and got really confused about what is "test case" in terms of QTestLib. I need some initialization to be done before each test runs, so I explored docs in Qt Assistant and found initTestCase() slot. So I just had to override it. But I was surprised to see that this slot is called only once. I read QTestLib docs once again and found this:

    initTestCase() will be called before the first testfunction is executed.
    cleanupTestCase() will be called after the last testfunction was executed.
    init() will be called before each testfunction is executed.
    cleanup() will be called after every testfunction.
    This confused me greatly. As far as I understand (at least it seemed to me that I understood that right) there is "test suite" which is a set of test cases (wikipedia and cppunit told me the same). It should make sense that there should be something like initTestSuite and initTestCase (the same with cleanup).
    As it appears in Qt:

    Qt's initTestCase corresponds to theory's initTestSuite and
    Qt's init corresponds to theory's initTestCase.

    I don't understand why these terms are rearanged in Qt.
    Doesn't this look a little bit wrong to you? Maybe someone knows the reason for this?
    I'm a rebel in the S.D.G.

  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: Misunderstanding QTestLib's TestCase term

    What if you interpret "initTestCase" as "test case which performs initialization"?

    Actually a "test suite" in terms of QtTestLib is a set of separate executables each performing a separate test composed from many test cases. That's my guess at least.
    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
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Misunderstanding QTestLib's TestCase term

    Quote Originally Posted by wysota View Post
    What if you interpret "initTestCase" as "test case which performs initialization"?
    I do treat it that way, but many of us will expect it to perform this initialization before each function.

    Quote Originally Posted by wysota View Post
    Actually a "test suite" in terms of QtTestLib is a set of separate executables each performing a separate test composed from many >>test cases<<. That's my guess at least.
    See, you also think of a test case as a one test function which is included in some set.

    wysota, were not you confused when you read the description of initTestCase, init, etc.?
    I'm a rebel in the S.D.G.

  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: Misunderstanding QTestLib's TestCase term

    Quote Originally Posted by lyuts View Post
    wysota, were not you confused when you read the description of initTestCase, init, etc.?
    No, I have read the documentation (and have seen a presentation on test lib) before I started coding my own tests.
    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
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Misunderstanding QTestLib's TestCase term

    Ok, I got your point of view.
    I'm a rebel in the S.D.G.

Similar Threads

  1. QtTest problem compiling basic testcase
    By hubbobubbo in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2009, 11:38
  2. QSortFilterProxyModel.invalidateFilter() misunderstanding
    By aspidites in forum Qt Programming
    Replies: 2
    Last Post: 23rd April 2009, 13:17
  3. parent() heirarchy misunderstanding?
    By KShots in forum Qt Programming
    Replies: 2
    Last Post: 16th October 2007, 18:18
  4. term does not evaluate to a function
    By :db:sStrong in forum General Programming
    Replies: 6
    Last Post: 18th April 2007, 10:54

Tags for this Thread

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.