Results 1 to 4 of 4

Thread: QtTest - Am I missing the point

  1. #1
    Join Date
    Dec 2009
    Posts
    62
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default QtTest - Am I missing the point

    Hi

    I was just looking at QtTest for unit testing but I must be missing something. Since each test will define its own main with the QTEST_MAIN(TestXXX) function. How do I set up the testing with many testcases, I can only have 1 main function?

    Is it supposed to be used in another way. Preferably I would like to have the unittest even in the same project as my application, is there a way to compile the tests individually. How are you doing this.

    Thanks

  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: QtTest - Am I missing the point

    Each private slot of your test class is a test function. Each test function can cover many test cases through data-driven 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.


  3. #3
    Join Date
    Feb 2006
    Location
    Kirovohrad, Ukraine
    Posts
    72
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: QtTest - Am I missing the point

    Quote Originally Posted by hubbobubbo View Post
    How do I set up the testing with many testcases, I can only have 1 main function?
    I'm also concerned about this problem. There seem to be no way to organize tests in hierarchy. Take xUnit testing framework family's approach as an example: there are test cases which can be organized in test suites, which in turn can be included into other test suites. All this stuff makes it possible to organize tests in a nice tree which mimics the project's structure and simplifies both navigation between code and corresponding tests. Also this tree has one entry point thus eliminating the need to find the right one.

    On the other hand there's QtTest framework. Personally I took tests for Qt Creator as a reference. Immediately two questions arose:
    1. How can I run all its tests in one go?
    2. How can I find a test that covers a particular piece of code?

    Quote Originally Posted by wysota View Post
    Each test function can cover many test cases through data-driven testing.
    That's a nice feature indeed, but it has quite a different goal. If I got it right it is similar to jUnit's and PhpUnit's data providers. They just feed the test with different sets of data to see how the same piece of code can handle it. So it cannot be used to test different parts of system, while hubbobubbo and I look for a way to organize tests for different pieces of code.

    Sorry for such an offensive manner, I'm really eager to utilize QtTest, but it's so irritating to miss features you've got used to while others tend to say "you don't need them". Maybe there's another way to achieve the same goals with QtTest but neither hubbobubbo nor me just couldn't manage to find them? Please share your experience so that we also can be happy

  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: QtTest - Am I missing the point

    Each test case is a separate private slot. You can have as many of them as you want and each of them can be executed with different input data. In result you get an executable testing a single unit of code (that's why it's called unit testing, isn't it?). You can group executables in hierarchies using directories according to a desired structure you wish to obtain. To execute all tests in one go simply have a script that will do it for you. The easiest way to do it on Unix is to issue:
    bash Code:
    1. find . -type f -perm +111 -exec "{}" \;
    To copy to clipboard, switch view to plain text mode 
    which will execute all executable files from all subdirectories of the current directory.
    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.


Similar Threads

  1. Replies: 6
    Last Post: 21st September 2009, 11:55
  2. how to paint scene point by point
    By elessaar in forum Qt Programming
    Replies: 8
    Last Post: 4th September 2008, 21:00
  3. lib("dnsapi")
    By CHeader in forum Newbie
    Replies: 10
    Last Post: 16th February 2008, 20:21
  4. Check a point inside or outside a road?
    By kstking in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2007, 19:48
  5. Moving the (0.0) point on the scene
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 6th September 2007, 16:34

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.